clean up unused idb functions (#537)
This commit is contained in:
parent
fd43dc6e5d
commit
431d1e1051
|
@ -15,6 +15,10 @@ import {
|
||||||
} from './constants'
|
} from './constants'
|
||||||
import { addKnownInstance, deleteKnownInstance } from './knownInstances'
|
import { addKnownInstance, deleteKnownInstance } from './knownInstances'
|
||||||
|
|
||||||
|
if (process.browser) {
|
||||||
|
require('indexeddb-getall-shim') // needed for Edge
|
||||||
|
}
|
||||||
|
|
||||||
const openReqs = {}
|
const openReqs = {}
|
||||||
const databaseCache = {}
|
const databaseCache = {}
|
||||||
|
|
||||||
|
@ -22,10 +26,6 @@ const DB_VERSION_INITIAL = 9
|
||||||
const DB_VERSION_SEARCH_ACCOUNTS = 10
|
const DB_VERSION_SEARCH_ACCOUNTS = 10
|
||||||
const DB_VERSION_CURRENT = 10
|
const DB_VERSION_CURRENT = 10
|
||||||
|
|
||||||
if (process.browser) {
|
|
||||||
require('indexeddb-getall-shim') // needed for Edge
|
|
||||||
}
|
|
||||||
|
|
||||||
function createDatabase (instanceName) {
|
function createDatabase (instanceName) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let req = indexedDB.open(instanceName, DB_VERSION_CURRENT)
|
let req = indexedDB.open(instanceName, DB_VERSION_CURRENT)
|
||||||
|
|
|
@ -15,9 +15,6 @@ import {
|
||||||
insertPinnedStatuses as _insertPinnedStatuses
|
insertPinnedStatuses as _insertPinnedStatuses
|
||||||
} from './timelines/pinnedStatuses'
|
} from './timelines/pinnedStatuses'
|
||||||
import {
|
import {
|
||||||
getNotificationTimeline as _getNotificationTimeline,
|
|
||||||
getStatusThread as _getStatusThread,
|
|
||||||
getStatusTimeline as _getStatusTimeline,
|
|
||||||
getTimeline as _getTimeline
|
getTimeline as _getTimeline
|
||||||
} from './timelines/pagination'
|
} from './timelines/pagination'
|
||||||
import {
|
import {
|
||||||
|
@ -34,10 +31,7 @@ import {
|
||||||
deleteStatusesAndNotifications as _deleteStatusesAndNotifications
|
deleteStatusesAndNotifications as _deleteStatusesAndNotifications
|
||||||
} from './timelines/deletion'
|
} from './timelines/deletion'
|
||||||
import {
|
import {
|
||||||
insertStatusThread as _insertStatusThread,
|
insertTimelineItems as _insertTimelineItems
|
||||||
insertTimelineItems as _insertTimelineItems,
|
|
||||||
insertTimelineNotifications as _insertTimelineNotifications,
|
|
||||||
insertTimelineStatuses as _insertTimelineStatuses
|
|
||||||
} from './timelines/insertion'
|
} from './timelines/insertion'
|
||||||
import {
|
import {
|
||||||
getCustomEmoji as _getCustomEmoji,
|
getCustomEmoji as _getCustomEmoji,
|
||||||
|
@ -86,18 +80,6 @@ export async function getPinnedStatuses (instanceName, accountId) {
|
||||||
return _getPinnedStatuses(instanceName, accountId)
|
return _getPinnedStatuses(instanceName, accountId)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getNotificationTimeline (instanceName, timeline, maxId, limit) {
|
|
||||||
return _getNotificationTimeline(instanceName, timeline, maxId, limit)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getStatusTimeline (instanceName, timeline, maxId, limit) {
|
|
||||||
return _getStatusTimeline(instanceName, timeline, maxId, limit)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getStatusThread (instanceName, statusId) {
|
|
||||||
return _getStatusThread(instanceName, statusId)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getTimeline (instanceName, timeline, maxId, limit) {
|
export async function getTimeline (instanceName, timeline, maxId, limit) {
|
||||||
return _getTimeline(instanceName, timeline, maxId, limit)
|
return _getTimeline(instanceName, timeline, maxId, limit)
|
||||||
}
|
}
|
||||||
|
@ -130,18 +112,6 @@ export async function deleteStatusesAndNotifications (instanceName, statusIds, n
|
||||||
return _deleteStatusesAndNotifications(instanceName, statusIds, notificationIds)
|
return _deleteStatusesAndNotifications(instanceName, statusIds, notificationIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function insertTimelineNotifications (instanceName, timeline, notifications) {
|
|
||||||
return _insertTimelineNotifications(instanceName, timeline, notifications)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function insertTimelineStatuses (instanceName, timeline, statuses) {
|
|
||||||
return _insertTimelineStatuses(instanceName, timeline, statuses)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function insertStatusThread (instanceName, statusId, statuses) {
|
|
||||||
return _insertStatusThread(instanceName, statusId, statuses)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function insertTimelineItems (instanceName, timeline, timelineItems) {
|
export async function insertTimelineItems (instanceName, timeline, timelineItems) {
|
||||||
return _insertTimelineItems(instanceName, timeline, timelineItems)
|
return _insertTimelineItems(instanceName, timeline, timelineItems)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ export function storeNotification (notificationsStore, statusesStore, accountsSt
|
||||||
putNotification(notificationsStore, notification)
|
putNotification(notificationsStore, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function insertTimelineNotifications (instanceName, timeline, notifications) {
|
async function insertTimelineNotifications (instanceName, timeline, notifications) {
|
||||||
for (let notification of notifications) {
|
for (let notification of notifications) {
|
||||||
setInCache(notificationsCache, instanceName, notification.id, notification)
|
setInCache(notificationsCache, instanceName, notification.id, notification)
|
||||||
setInCache(accountsCache, instanceName, notification.account.id, notification.account)
|
setInCache(accountsCache, instanceName, notification.account.id, notification.account)
|
||||||
|
@ -71,7 +71,7 @@ export async function insertTimelineNotifications (instanceName, timeline, notif
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function insertTimelineStatuses (instanceName, timeline, statuses) {
|
async function insertTimelineStatuses (instanceName, timeline, statuses) {
|
||||||
for (let status of statuses) {
|
for (let status of statuses) {
|
||||||
cacheStatus(status, instanceName)
|
cacheStatus(status, instanceName)
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ export async function insertTimelineStatuses (instanceName, timeline, statuses)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function insertStatusThread (instanceName, statusId, statuses) {
|
async function insertStatusThread (instanceName, statusId, statuses) {
|
||||||
for (let status of statuses) {
|
for (let status of statuses) {
|
||||||
cacheStatus(status, instanceName)
|
cacheStatus(status, instanceName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { fetchStatus } from './fetchStatus'
|
||||||
import { fetchNotification } from './fetchNotification'
|
import { fetchNotification } from './fetchNotification'
|
||||||
import { TIMELINE_BATCH_SIZE } from '../../_static/timelines'
|
import { TIMELINE_BATCH_SIZE } from '../../_static/timelines'
|
||||||
|
|
||||||
export async function getNotificationTimeline (instanceName, timeline, maxId, limit) {
|
async function getNotificationTimeline (instanceName, timeline, maxId, limit) {
|
||||||
let storeNames = [NOTIFICATION_TIMELINES_STORE, NOTIFICATIONS_STORE, STATUSES_STORE, ACCOUNTS_STORE]
|
let storeNames = [NOTIFICATION_TIMELINES_STORE, NOTIFICATIONS_STORE, STATUSES_STORE, ACCOUNTS_STORE]
|
||||||
const db = await getDatabase(instanceName)
|
const db = await getDatabase(instanceName)
|
||||||
return dbPromise(db, storeNames, 'readonly', (stores, callback) => {
|
return dbPromise(db, storeNames, 'readonly', (stores, callback) => {
|
||||||
|
@ -35,7 +35,7 @@ export async function getNotificationTimeline (instanceName, timeline, maxId, li
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getStatusTimeline (instanceName, timeline, maxId, limit) {
|
async function getStatusTimeline (instanceName, timeline, maxId, limit) {
|
||||||
let storeNames = [STATUS_TIMELINES_STORE, STATUSES_STORE, ACCOUNTS_STORE]
|
let storeNames = [STATUS_TIMELINES_STORE, STATUSES_STORE, ACCOUNTS_STORE]
|
||||||
const db = await getDatabase(instanceName)
|
const db = await getDatabase(instanceName)
|
||||||
return dbPromise(db, storeNames, 'readonly', (stores, callback) => {
|
return dbPromise(db, storeNames, 'readonly', (stores, callback) => {
|
||||||
|
@ -54,7 +54,7 @@ export async function getStatusTimeline (instanceName, timeline, maxId, limit) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getStatusThread (instanceName, statusId) {
|
async function getStatusThread (instanceName, statusId) {
|
||||||
let storeNames = [THREADS_STORE, STATUSES_STORE, ACCOUNTS_STORE]
|
let storeNames = [THREADS_STORE, STATUSES_STORE, ACCOUNTS_STORE]
|
||||||
const db = await getDatabase(instanceName)
|
const db = await getDatabase(instanceName)
|
||||||
return dbPromise(db, storeNames, 'readonly', (stores, callback) => {
|
return dbPromise(db, storeNames, 'readonly', (stores, callback) => {
|
||||||
|
|
Loading…
Reference in New Issue