Skip to content

Commit

Permalink
Fixed aliases staying in storage on links removal
Browse files Browse the repository at this point in the history
  • Loading branch information
victrme committed Feb 27, 2022
1 parent 330b562 commit c8c8b3d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
23 changes: 11 additions & 12 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ const version = '1.12.0'
const bonjourrCache = 'bonjourr-v' + version

const filesToChache = [
'release/',
'release/settings.html',
'release/manifest.webmanifest',
'release/src/scripts/main.js',
'release/src/styles/style.css',
'release/src/assets/favicon-128x128.png',
'release/src/assets/favicon-512x512.png',
'release/src/assets/apple-touch-icon.png',
'release/src/assets/interface/gear.svg',
'release/src/assets/interface/loading.gif',
'/',
'/settings.html',
'/manifest.webmanifest',
'/src/scripts/main.js',
'/src/styles/style.css',
'/src/assets/favicon-128x128.png',
'/src/assets/favicon-512x512.png',
'/src/assets/apple-touch-icon.png',
'/src/assets/interface/gear.svg',
'/src/assets/interface/loading.gif',
]

const weatherList = [
Expand All @@ -29,8 +29,7 @@ const weatherList = [
'overcastclouds',
]

const addWeatherIcons = (time) =>
weatherList.forEach((elem) => filesToChache.push(`release/src/assets/weather/${time}/${elem}.png`))
const addWeatherIcons = (time) => weatherList.forEach((elem) => filesToChache.push(`/src/assets/weather/${time}/${elem}.png`))

addWeatherIcons('day')
addWeatherIcons('night')
Expand Down
11 changes: 5 additions & 6 deletions src/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ function quickLinks(event, that, initStorage) {
e.target.previousElementSibling.value = ''
e.target.classList.remove('shown')
}

id('e_delete').onclick = function () {
removeLinkSelection()
removeblock(parseInt(id('editlink').getAttribute('index')))
Expand Down Expand Up @@ -592,7 +593,6 @@ function quickLinks(event, that, initStorage) {
case 'icon': {
// Updates dom
parent.querySelector('img').src = updated.icon

const previousIconURL = allLinks[i].icon

// Saves to an alias if icon is too big
Expand All @@ -605,8 +605,8 @@ function quickLinks(event, that, initStorage) {
}

// If it was an alias before, but not after being updated
else if (previousWasAlias) {
chrome.storage.sync.remove(allLinks[i].icon)
else if (previousIconURL.startsWith('alias:')) {
chrome.storage.sync.remove(previousIconURL)
}

break
Expand Down Expand Up @@ -654,9 +654,8 @@ function quickLinks(event, that, initStorage) {
function removeblock(index) {
chrome.storage.sync.get('links', (data) => {
// Remove alias from storage
if (data.links[index].icon.startsWith('alias:')) {
chrome.storage.local.remove(data.links[index].icon)
}
const icon = data.links[index].icon
if (icon.startsWith('alias:')) chrome.storage.sync.remove(icon)

data.links.splice(index, 1)

Expand Down

0 comments on commit c8c8b3d

Please sign in to comment.