diff --git a/routes/_database/databaseLifecycle.js b/routes/_database/databaseLifecycle.js index 011273d..3d7d23b 100644 --- a/routes/_database/databaseLifecycle.js +++ b/routes/_database/databaseLifecycle.js @@ -15,6 +15,10 @@ import { } from './constants' import { addKnownInstance, deleteKnownInstance } from './knownInstances' +if (process.browser) { + require('indexeddb-getall-shim') // needed for Edge +} + const openReqs = {} const databaseCache = {} @@ -22,10 +26,6 @@ const DB_VERSION_INITIAL = 9 const DB_VERSION_SEARCH_ACCOUNTS = 10 const DB_VERSION_CURRENT = 10 -if (process.browser) { - require('indexeddb-getall-shim') // needed for Edge -} - function createDatabase (instanceName) { return new Promise((resolve, reject) => { let req = indexedDB.open(instanceName, DB_VERSION_CURRENT) diff --git a/routes/_database/databaseWorker.js b/routes/_database/databaseWorker.js index d652e16..46ea7df 100644 --- a/routes/_database/databaseWorker.js +++ b/routes/_database/databaseWorker.js @@ -15,9 +15,6 @@ import { insertPinnedStatuses as _insertPinnedStatuses } from './timelines/pinnedStatuses' import { - getNotificationTimeline as _getNotificationTimeline, - getStatusThread as _getStatusThread, - getStatusTimeline as _getStatusTimeline, getTimeline as _getTimeline } from './timelines/pagination' import { @@ -34,10 +31,7 @@ import { deleteStatusesAndNotifications as _deleteStatusesAndNotifications } from './timelines/deletion' import { - insertStatusThread as _insertStatusThread, - insertTimelineItems as _insertTimelineItems, - insertTimelineNotifications as _insertTimelineNotifications, - insertTimelineStatuses as _insertTimelineStatuses + insertTimelineItems as _insertTimelineItems } from './timelines/insertion' import { getCustomEmoji as _getCustomEmoji, @@ -86,18 +80,6 @@ export async function 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) { return _getTimeline(instanceName, timeline, maxId, limit) } @@ -130,18 +112,6 @@ export async function deleteStatusesAndNotifications (instanceName, statusIds, n 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) { return _insertTimelineItems(instanceName, timeline, timelineItems) } diff --git a/routes/_database/timelines/insertion.js b/routes/_database/timelines/insertion.js index 2e7dabe..dd04852 100644 --- a/routes/_database/timelines/insertion.js +++ b/routes/_database/timelines/insertion.js @@ -52,7 +52,7 @@ export function storeNotification (notificationsStore, statusesStore, accountsSt putNotification(notificationsStore, notification) } -export async function insertTimelineNotifications (instanceName, timeline, notifications) { +async function insertTimelineNotifications (instanceName, timeline, notifications) { for (let notification of notifications) { setInCache(notificationsCache, instanceName, notification.id, notification) 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) { 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) { cacheStatus(status, instanceName) } diff --git a/routes/_database/timelines/pagination.js b/routes/_database/timelines/pagination.js index ea90c75..3cfdae5 100644 --- a/routes/_database/timelines/pagination.js +++ b/routes/_database/timelines/pagination.js @@ -15,7 +15,7 @@ import { fetchStatus } from './fetchStatus' import { fetchNotification } from './fetchNotification' 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] const db = await getDatabase(instanceName) 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] const db = await getDatabase(instanceName) 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] const db = await getDatabase(instanceName) return dbPromise(db, storeNames, 'readonly', (stores, callback) => {