Get native theme through IPC not remote

This commit is contained in:
Fedor Indutny 2021-06-30 11:57:43 -07:00 committed by GitHub
parent d2cc8e5aa9
commit 71572db7a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 227 additions and 60 deletions

View file

@ -20,7 +20,7 @@ const storageMap = new Map();
// To replicate logic we have on the client side
global.window = {
SignalContext: new SignalContext(),
SignalContext: undefined,
log: {
info: (...args) => console.log(...args),
warn: (...args) => console.warn(...args),
@ -38,6 +38,21 @@ global.window = {
isValidGuid,
};
const fakeIPC = {
sendSync(channel) {
// See `ts/context/NativeThemeListener.ts`
if (channel === 'native-theme:init') {
return { shouldUseDarkColors: true };
}
throw new Error(`Unsupported sendSync channel: ${channel}`);
},
on() {},
};
global.window.SignalContext = new SignalContext(fakeIPC);
// For ducks/network.getEmptyState()
global.navigator = {};
global.WebSocket = {};