Skip to content

Commit

Permalink
Removed ghost funcs, canDisplay before awaits
Browse files Browse the repository at this point in the history
  • Loading branch information
victrme committed May 13, 2022
1 parent dc62052 commit 8a63d97
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ async function quotes(event, that, init) {
async function newQuote(lang, type) {
try {
if (!navigator.onLine) {
return getFromStorage() // Offline, return whatever is in storage
return []
}

// Fetch a random quote from the quotes API
Expand All @@ -2085,12 +2085,12 @@ async function quotes(event, that, init) {
}
} catch (error) {
console.warn(error)
return getFromStorage()
return []
}
}

function insertToDom(values) {
if (values === null) return
if (!values) return
id('quote').textContent = values.content
id('author').textContent = values.author
}
Expand Down Expand Up @@ -2178,8 +2178,9 @@ async function quotes(event, that, init) {

// Init
chrome.storage.local.get('quotesCache', async (local) => {
const { lang, quotes } = init
canDisplayInterface('quotes')

const { lang, quotes } = init
let needsNewQuote = freqControl('get', quotes.frequency, quotes.last)
let cache = local.quotesCache
let quote = {}
Expand Down Expand Up @@ -2209,8 +2210,6 @@ async function quotes(event, that, init) {
if (quotes.author) id('author').classList.add('alwaysVisible')
insertToDom(quote)
display(true)

canDisplayInterface('quotes')
})
}

Expand Down

0 comments on commit 8a63d97

Please sign in to comment.