Skip to content

Commit

Permalink
Merge pull request #7 from nkolba/get-context-on-join-channel
Browse files Browse the repository at this point in the history
missing listenerIds at top of message structure when sending initial …
  • Loading branch information
nkolba authored Mar 31, 2022
2 parents 3fe1fef + a49c974 commit e9fc800
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/main/src/listeners/fdc3Listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,18 +673,23 @@ export const joinViewToChannel = (
if (channelContext) {
const ctx = channelContext.length > 0 ? channelContext[0] : null;
let contextSent = false;
if (ctx && !restoreOnly) {

if (ctx && (restoreOnly === undefined || !restoreOnly)) {
// send to individual listenerIds

view.listeners.forEach((l) => {
//if this is not an intent listener, and not set for a specific channel, and not set for a non-matching context type - send the context to the listener
if (!l.intent) {
if (
(!l.channel || (l.channel && l.channel === channel)) &&
(!l.channel ||
l.channel === 'default' ||
(l.channel && l.channel === channel)) &&
(!l.contextType ||
(l.contextType && l.contextType === ctx.type))
) {
view.content.webContents.send(TOPICS.FDC3_CONTEXT, {
topic: 'context',
listenerIds: [l.listenerId],
data: { context: ctx, listenerId: l.listenerId },
source: view.id,
});
Expand Down
5 changes: 4 additions & 1 deletion packages/preload/src/view/contentConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ const wireTopic = (topic: string, config?: any): void => {
listener: function (msg: FDC3Message) {
if (msg) {
document.dispatchEvent(
utils.fdc3Event(`return_${eventId}`,((msg && msg.data) ? msg.data : {})),
utils.fdc3Event(
`return_${eventId}`,
msg && msg.data ? msg.data : {},
),
);
}
},
Expand Down

0 comments on commit e9fc800

Please sign in to comment.