1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-27 04:03:00 +02:00

Remove logic out of notification content scripts

This commit is contained in:
Daniel James Smith 2021-10-18 16:42:32 +02:00
parent fd8de4ca0c
commit 95e9387314
No known key found for this signature in database
GPG Key ID: 03E4BD365FF06726
3 changed files with 20 additions and 27 deletions

View File

@ -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':

View File

@ -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);

View File

@ -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);
});
}