Skip to content

Commit 660182d

Browse files
authored
Merge pull request #1379 from kemerava/feature/context-clearing
Context Clearing Merging to the new branch, will create another PR from that into main
2 parents d4a261a + a7e5c4b commit 660182d

18 files changed

Lines changed: 717 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1414

1515
* Added details of and procedures for resolving fully-qualified appIds and unqualified appIds in the API and Bridging Parts of the Standard. ([#1523](https://github.com/finos/FDC3/pull/1523))
1616

17+
* Added `clearContext` function and associated `contextClearedEvent` to the `Channel` API, to be able to clear specific or all context types from the channel. ([#1379](https://github.com/finos/FDC3/pull/1379))
18+
1719
### Changed
1820

1921
### Deprecated
@@ -51,6 +53,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5153
* Added .NET docs for Events to API reference. ([#1441](https://github.com/finos/FDC3/pull/1441))
5254
* Setup package publishing for mono-repo packages. ([#1520](https://github.com/finos/FDC3/pull/1520))
5355
* Implementation PR for FDC3 for the Web ([#896](https://github.com/finos/FDC3/pull/896))
56+
- resolves ([#1209](https://github.com/finos/FDC3/issues/1209))
57+
- resolves ([#1297](https://github.com/finos/FDC3/issues/1297))
58+
- resolves ([#1429](https://github.com/finos/FDC3/issues/1429))
59+
- resolves ([#1430](https://github.com/finos/FDC3/issues/1430))
60+
- resolves ([#1431](https://github.com/finos/FDC3/issues/1431))
61+
- resolves ([#1432](https://github.com/finos/FDC3/issues/1432))
62+
- resolves ([#1433](https://github.com/finos/FDC3/issues/1433))
63+
- resolves ([#1468](https://github.com/finos/FDC3/issues/1468))
64+
- resolves ([#810](https://github.com/finos/FDC3/issues/810))
65+
- resolves ([#832](https://github.com/finos/FDC3/issues/832))
66+
- resolves ([#1487](https://github.com/finos/FDC3/issues/1487))
67+
- resolves ([#1488](https://github.com/finos/FDC3/issues/1488))
5468
* Adjusted reference Desktop Agent implementation for FDC3 for Web to open a new app instance when raiseIntent is called with an appId but no instanceId ([#1556](https://github.com/finos/FDC3/pull/1556))
5569

5670
### Changed

package-lock.json

Lines changed: 7 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/fdc3-agent-proxy/src/channels/DefaultChannel.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import { ContextHandler, DisplayMetadata, Listener, Channel } from '@finos/fdc3-standard';
1+
import { ContextHandler, DisplayMetadata, Listener, Channel, EventHandler } from '@finos/fdc3-standard';
22
import { Context } from '@finos/fdc3-context';
33
import { Messaging } from '../Messaging';
44
import { DefaultContextListener } from '../listeners/DefaultContextListener';
55
import {
66
BroadcastRequest,
77
BroadcastResponse,
8+
ClearContextRequest,
9+
ClearContextResponse,
810
GetCurrentContextRequest,
911
GetCurrentContextResponse,
1012
} from '@finos/fdc3-schema/generated/api/BrowserTypes';
13+
import { RegisterableListener } from '../listeners/RegisterableListener';
14+
import { EventListener } from '../listeners/EventListener';
1115

1216
export class DefaultChannel implements Channel {
1317
protected readonly messaging: Messaging;
@@ -98,4 +102,30 @@ export class DefaultChannel implements Channel {
98102
await listener.register();
99103
return listener;
100104
}
105+
106+
async clearContext(contextType?: string): Promise<void> {
107+
// first, ensure channel state is up-to-date
108+
const request: ClearContextRequest = {
109+
meta: this.messaging.createMeta(),
110+
payload: {
111+
channelId: this.id,
112+
contextType: contextType ?? null,
113+
},
114+
type: 'clearContextRequest',
115+
};
116+
await this.messaging.exchange<ClearContextResponse>(request, 'clearContextResponse', this.messageExchangeTimeout);
117+
}
118+
119+
async addEventListener(type: string | null, handler: EventHandler): Promise<Listener> {
120+
let listener: RegisterableListener;
121+
switch (type) {
122+
case 'contextCleared':
123+
listener = new EventListener(this.messaging, 'contextCleared', handler);
124+
break;
125+
default:
126+
throw new Error('Unsupported event type: ' + type);
127+
}
128+
await listener.register();
129+
return listener;
130+
}
101131
}

0 commit comments

Comments
 (0)