Skip to content

Commit 8014b5d

Browse files
author
Shane Osbourne
committed
windows request
1 parent cfead29 commit 8014b5d

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

packages/messaging/lib/windows.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ export class WindowsMessagingTransport {
3939
// @ts-ignore
4040
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4141
notify(msg) {
42-
42+
4343
console.log('🙏 windows transport, sending a notification', JSON.stringify(msg, null, 2))
4444
const raw = {};
4545
raw.Name = msg.method;
4646
raw.Feature = msg.context;
4747
raw.SubFeatureName = msg.featureName;
4848
raw.Data = JSON.parse(JSON.stringify(raw.params || {}));
49-
49+
5050
this.config.methods.postMessage(raw)
5151
}
5252
/**
@@ -57,7 +57,13 @@ export class WindowsMessagingTransport {
5757
// @ts-ignore
5858
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5959
request(msg, opts = {}) {
60-
this.config.methods.postMessage(msg)
60+
const raw = {};
61+
raw.Name = msg.method;
62+
raw.Feature = msg.context;
63+
raw.SubFeatureName = msg.featureName;
64+
raw.Data = JSON.parse(JSON.stringify(msg.params || {}))
65+
raw.Id = msg.id;
66+
this.config.methods.postMessage(raw)
6167
const comparator = (eventData) => {
6268
return eventData.featureName === msg.featureName
6369
&& eventData.context === msg.context

packages/special-pages/pages/duckplayer/src/js/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,13 @@ const Comms = {
345345
const messaging = new Messaging(messageContext, opts)
346346
Comms.messaging = new DuckPlayerPageMessages(messaging)
347347
}
348+
Comms.messaging.getUserValues().then((value) => {
349+
if ('enabled' in value.privatePlayerMode) {
350+
Setting.setState(true)
351+
} else {
352+
Setting.setState(false)
353+
}
354+
})
348355
Comms.messaging?.onUserValuesChanged(value => {
349356
if ('enabled' in value.privatePlayerMode) {
350357
Setting.setState(true)

packages/special-pages/pages/duckplayer/src/js/messages.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export class DuckPlayerPageMessages {
2323
this.messaging.notify('setUserValues', userValues)
2424
}
2525

26+
/**
27+
* This is sent when the user wants to set Duck Player as the default.
28+
* @return {Promise<UserValues>}
29+
*/
30+
getUserValues () {
31+
return this.messaging.request('getUserValues')
32+
}
33+
2634
/**
2735
* This occurs when a user has clicked on the 'Settings Cog'
2836
*

0 commit comments

Comments
 (0)