Skip to content

Commit

Permalink
Add notification for missing settings
Browse files Browse the repository at this point in the history
  • Loading branch information
crittermike committed May 1, 2024
1 parent 45a89ae commit 5b1e2f0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"management",
"debugger",
"scripting",
"notifications",

This comment has been minimized.

Copy link
@swrobel

swrobel May 7, 2024

Thanks for maintaining this! It's probably worth updating the permissions wiki to mention this one.

"activeTab"
],
"host_permissions": ["*://*/*"],
Expand Down
17 changes: 6 additions & 11 deletions app/options/options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,20 +356,15 @@ export default {
}
};
async function loadKeys() {
const savedKeys = await chrome.storage.local.get('keys');
if (savedKeys.keys) {
const savedKeys = await chrome.storage.local.get('keys')
if (savedKeys.keys) {
this.keys = [...JSON.parse(savedKeys.keys)];
} else {
// Fallback to localStorage if chrome.storage.local has no keys.
// This supports the manifest v2 to v3 migratoin path.
this.keys = localStorage.shortkeys ? JSON.parse(localStorage.shortkeys).keys : [{}];
}
} else {
// Fallback to localStorage if chrome.storage.local has no keys.
// This supports the manifest v2 to v3 migratoin path.
this.keys = localStorage.shortkeys ? JSON.parse(localStorage.shortkeys).keys : [{}];
}
loadKeys();
chrome.bookmarks.getTree(processBookmarks)
},
};
Expand Down
20 changes: 19 additions & 1 deletion app/scripts/service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,30 @@ browser.commands.onCommand.addListener(function (command) {
})

browser.runtime.onMessage.addListener(function (request, sender, sendResponse) {
chrome.notifications.onButtonClicked.addListener((notificationId, buttonIndex) => {
if (notificationId === 'settingsNotification' && buttonIndex === 0) {
// Open the options page if exists
chrome.runtime.openOptionsPage();
}
});
const action = request.action
if (action === 'getKeys') {
(async () => {
const currentUrl = request.url
const keysFromStorage = await chrome.storage.local.get("keys")
const settings = { keys: JSON.parse(keysFromStorage.keys) }
const settings = {}
if (keysFromStorage.keys) {
settings.keys = JSON.parse(keysFromStorage.keys)
} else {
chrome.notifications.create('settingsNotification', {
type: 'basic',
iconUrl: '/images/icon_128.png',
title: 'Shortkeys upgraded',
message: 'Action needed: re-save your shortcuts to continue using them.',
requireInteraction: true,
buttons: [{title: "Open and re-save settings"}]
});
}
let keys = []

if (settings.keys.length > 0) {
Expand Down

0 comments on commit 5b1e2f0

Please sign in to comment.