Skip to content

Commit

Permalink
Merge 706e118 into 13e6bcb
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Aug 13, 2021
2 parents 13e6bcb + 706e118 commit ea36243
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
14 changes: 3 additions & 11 deletions src/database/idbInterface.js
Expand Up @@ -8,7 +8,7 @@ import {
} from './constants'
import { transformEmojiData } from './utils/transformEmojiData'
import { extractTokens } from './utils/extractTokens'
import { getAllIDB, getAllKeysIDB, getIDB } from './idbUtil'
import { getAllIDB, getIDB } from './idbUtil'
import { findCommonMembers } from './utils/findCommonMembers'
import { normalizeTokens } from './utils/normalizeTokens'

Expand Down Expand Up @@ -67,11 +67,10 @@ export async function loadData (db, emojiData, url, eTag) {
await dbPromise(db, [STORE_EMOJI, STORE_KEYVALUE], MODE_READWRITE, ([emojiStore, metaStore]) => {
let oldETag
let oldUrl
let oldKeys
let todo = 0

function checkFetched () {
if (++todo === 3) {
if (++todo === 2) { // 2 requests made
onFetched()
}
}
Expand All @@ -82,9 +81,7 @@ export async function loadData (db, emojiData, url, eTag) {
return
}
// delete old data
for (const key of oldKeys) {
emojiStore.delete(key)
}
emojiStore.clear()
// insert new data
for (const data of transformedData) {
emojiStore.put(data)
Expand All @@ -103,11 +100,6 @@ export async function loadData (db, emojiData, url, eTag) {
oldUrl = result
checkFetched()
})

getAllKeysIDB(emojiStore, undefined, result => {
oldKeys = result
checkFetched()
})
})
performance.measure('commitAllData', 'commitAllData')
} finally {
Expand Down
4 changes: 0 additions & 4 deletions src/database/idbUtil.js
Expand Up @@ -11,7 +11,3 @@ export function getIDB (store, key, cb) {
export function getAllIDB (store, key, cb) {
callStore(store, 'getAll', key, cb)
}

export function getAllKeysIDB (store, key, cb) {
callStore(store, 'getAllKeys', key, cb)
}

0 comments on commit ea36243

Please sign in to comment.