Skip to content

Commit

Permalink
webclipper challenge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3orblade committed Mar 2, 2024
1 parent e2a52e6 commit 1500456
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/js/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ window.Electron = {
},
send: function () {},
currentWindow: function () {
return { windowId: 1 };
return {};
},
Api: () => {},
};
Expand Down
4 changes: 2 additions & 2 deletions extension/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare global {
window.$ = $;
window.isExtension = true;
window.Electron = {
currentWindow: () => ({ windowId: 1 }),
currentWindow: () => ({}),
Api: () => {},
};

Expand All @@ -41,7 +41,7 @@ window.AnytypeGlobalConfig = {
emojiUrl: Extension.clipper.emojiUrl,
menuBorderTop: 16,
menuBorderBottom: 16,
debug: {},
debug: { mw: true },
};

let rootId = '';
Expand Down
8 changes: 5 additions & 3 deletions src/ts/lib/api/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class Dispatcher {
const electron = UtilCommon.getElectron();
const currentWindow = electron.currentWindow();
const { windowId } = currentWindow;
const isMainWindow = windowId === 1;

if (traceId) {
ctx.push(traceId);
Expand Down Expand Up @@ -224,7 +225,7 @@ class Dispatcher {
};

case 'accountLinkChallenge': {
if (windowId !== 1) {
if (!isMainWindow) {
break;
};

Expand All @@ -237,6 +238,7 @@ class Dispatcher {
theme: commonStore.getThemeClass(),
lang: commonStore.interfaceLang,
}, '*'), false);
win.focus();

window.setTimeout(() => {
try { win.close(); } catch (e) { /**/ };
Expand Down Expand Up @@ -968,7 +970,7 @@ class Dispatcher {

notificationStore.add(item);

if ((windowId == 1) && !electron.isFocused()) {
if (isMainWindow && !electron.isFocused()) {
new window.Notification(UtilCommon.stripTags(item.title), { body: UtilCommon.stripTags(item.text) }).onclick = () => electron.focus();
};
break;
Expand All @@ -980,7 +982,7 @@ class Dispatcher {
};

case 'payloadBroadcast': {
if (electron.currentWindow().windowId !== 1) {
if (!isMainWindow) {
break;
};

Expand Down

0 comments on commit 1500456

Please sign in to comment.