Skip to content

Commit

Permalink
refs #2500 Skip cache
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Dec 31, 2022
1 parent 0009116 commit c172d6c
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
IpcMainInvokeEvent
} from 'electron'

import Datastore from 'nedb'
import crypto from 'crypto'
import log from 'electron-log'
import windowStateKeeper from 'electron-window-state'
Expand All @@ -42,9 +41,6 @@ import { LocalAccount } from '~/src/types/localAccount'
import { LocalTag } from '~/src/types/localTag'
import { Notify } from '~/src/types/notify'
// import { StreamingError } from '~/src/errors/streamingError'
import HashtagCache from './cache/hashtag'
import AccountCache from './cache/account'
import { InsertAccountCache } from '~/src/types/insertAccountCache'
import { Proxy } from '~/src/types/proxy'
import ProxyConfiguration from './proxy'
import { Menu as MenuPreferences } from '~/src/types/preference'
Expand Down Expand Up @@ -127,15 +123,6 @@ const preferencesDBPath = process.env.NODE_ENV === 'production' ? userData + './

const settingsDBPath = process.env.NODE_ENV === 'production' ? userData + './db/settings.json' : 'settings.json'

/**
* Cache path
*/
const hashtagCachePath = process.env.NODE_ENV === 'production' ? userData + '/cache/hashtag.db' : 'cache/hashtag.db'
const hashtagCache = new HashtagCache(hashtagCachePath)

const accountCachePath = process.env.NODE_ENV === 'production' ? userData + '/cache/account.db' : 'cache/account.db'
const accountCache = new AccountCache(accountCachePath)

const soundBasePath =
process.env.NODE_ENV === 'development' ? path.join(__dirname, '../../build/sounds/') : path.join(process.resourcesPath!, 'build/sounds/')
const iconBasePath =
Expand Down Expand Up @@ -1147,30 +1134,20 @@ ipcMain.handle(

// Cache
ipcMain.handle('get-cache-hashtags', async (_: IpcMainInvokeEvent) => {
const tags = await hashtagCache.listTags()
return tags
// TODO:
return []
})

ipcMain.handle('insert-cache-hashtags', async (_: IpcMainInvokeEvent, tags: Array<string>) => {
await Promise.all(
tags.map(async name => {
await hashtagCache.insertHashtag(name).catch(err => console.error(err))
})
)
ipcMain.handle('insert-cache-hashtags', async (_: IpcMainInvokeEvent) => {
return null
})

ipcMain.handle('get-cache-accounts', async (_: IpcMainInvokeEvent, ownerID: string) => {
const accounts = await accountCache.listAccounts(ownerID)
return accounts
ipcMain.handle('get-cache-accounts', async (_: IpcMainInvokeEvent) => {
return []
})

ipcMain.handle('insert-cache-accounts', async (_: IpcMainInvokeEvent, obj: InsertAccountCache) => {
const { ownerID, accts } = obj
Promise.all(
accts.map(async acct => {
await accountCache.insertAccount(ownerID, acct).catch(err => console.error(err))
})
)
ipcMain.handle('insert-cache-accounts', async (_: IpcMainInvokeEvent) => {
return []
})

// Application control
Expand Down

0 comments on commit c172d6c

Please sign in to comment.