Remove logic out of notification content scripts
This commit is contained in:
parent
fd8de4ca0c
commit
95e9387314
|
@ -23,6 +23,7 @@ import { PolicyType } from 'jslib-common/enums/policyType';
|
|||
import AddChangePasswordQueueMessage from './models/addChangePasswordQueueMessage';
|
||||
import AddLoginQueueMessage from './models/addLoginQueueMessage';
|
||||
import { NotificationQueueMessageType } from './models/NotificationQueueMessageType';
|
||||
import lockedVaultPendingNotificationsItem from './models/lockedVaultPendingNotificationsItem';
|
||||
|
||||
export default class NotificationBackground {
|
||||
|
||||
|
@ -75,6 +76,18 @@ export default class NotificationBackground {
|
|||
break;
|
||||
case 'bgAddSave':
|
||||
case 'bgChangeSave':
|
||||
if (await this.vaultTimeoutService.isLocked()) {
|
||||
const retryMessage: lockedVaultPendingNotificationsItem = {
|
||||
commandToRetry: {
|
||||
msg: msg,
|
||||
sender: sender,
|
||||
},
|
||||
target: 'notification.background',
|
||||
};
|
||||
await BrowserApi.tabSendMessageData(sender.tab, 'addToLockedVaultPendingNotifications', retryMessage);
|
||||
await BrowserApi.tabSendMessageData(sender.tab, 'promptForLogin');
|
||||
return;
|
||||
}
|
||||
await this.saveOrUpdateCredentials(sender.tab, msg.folder);
|
||||
break;
|
||||
case 'bgNeverSave':
|
||||
|
|
|
@ -22,6 +22,13 @@ window.addEventListener('message', event => {
|
|||
}, false);
|
||||
|
||||
chrome.runtime.onMessage.addListener(event => {
|
||||
if (event.command === 'promptForLogin') {
|
||||
chrome.runtime.sendMessage(event);
|
||||
}
|
||||
|
||||
if (event.command === 'addToLockedVaultPendingNotifications') {
|
||||
chrome.runtime.sendMessage(event);
|
||||
}
|
||||
|
||||
if (event.command === 'unlockCompleted') {
|
||||
chrome.runtime.sendMessage(event);
|
||||
|
|
|
@ -70,20 +70,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
command: 'bgAddSave',
|
||||
folder: folderId,
|
||||
};
|
||||
|
||||
if (isVaultLocked) {
|
||||
sendPlatformMessage({
|
||||
command: 'promptForLogin'
|
||||
});
|
||||
|
||||
sendPlatformMessage({
|
||||
command: 'addToLockedVaultPendingNotifications',
|
||||
from: 'notificationBar',
|
||||
retryItem: bgAddSaveMessage
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
sendPlatformMessage(bgAddSaveMessage);
|
||||
});
|
||||
|
||||
|
@ -115,19 +101,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
const bgChangeSaveMessage = {
|
||||
command: 'bgChangeSave'
|
||||
};
|
||||
|
||||
if (isVaultLocked) {
|
||||
sendPlatformMessage({
|
||||
command: 'promptForLogin'
|
||||
});
|
||||
|
||||
sendPlatformMessage({
|
||||
command: 'addToLockedVaultPendingNotifications',
|
||||
from: 'notificationBar',
|
||||
retryItem: bgChangeSaveMessage,
|
||||
});
|
||||
return;
|
||||
}
|
||||
sendPlatformMessage(bgChangeSaveMessage);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue