refactor: Use invoke for ipc to get cache hashtags
This commit is contained in:
parent
46a0087c78
commit
d2ca00354b
|
@ -1025,9 +1025,9 @@ ipcMain.handle('update-unread-notification', async (_: IpcMainInvokeEvent, confi
|
|||
})
|
||||
|
||||
// Cache
|
||||
ipcMain.on('get-cache-hashtags', async (event: IpcMainEvent) => {
|
||||
ipcMain.handle('get-cache-hashtags', async (_: IpcMainInvokeEvent) => {
|
||||
const tags = await hashtagCache.listTags()
|
||||
event.sender.send('response-get-cache-hashtags', tags)
|
||||
return tags
|
||||
})
|
||||
|
||||
ipcMain.on('insert-cache-hashtags', (event: IpcMainEvent, tags: Array<string>) => {
|
||||
|
|
|
@ -197,10 +197,9 @@ const actions: ActionTree<StatusState, RootState> = {
|
|||
commit(MUTATION_TYPES.CLEAR_FILTERED_HASHTAGS)
|
||||
commit(MUTATION_TYPES.FILTERED_SUGGESTION_FROM_HASHTAGS)
|
||||
const { word, start } = wordStart
|
||||
const searchCache = () => {
|
||||
return new Promise(resolve => {
|
||||
const searchCache = async () => {
|
||||
const target = word.replace('#', '')
|
||||
win.ipcRenderer.once('response-get-cache-hashtags', (_, tags: Array<LocalTag>) => {
|
||||
const tags: Array<LocalTag> = await win.ipcRenderer.invoke('get-cache-hashtags')
|
||||
const matched = tags.map(tag => tag.tagName).filter(tag => tag.includes(target))
|
||||
if (matched.length === 0) throw new Error('Empty')
|
||||
commit(MUTATION_TYPES.APPEND_FILTERED_HASHTAGS, matched)
|
||||
|
@ -208,10 +207,7 @@ const actions: ActionTree<StatusState, RootState> = {
|
|||
commit(MUTATION_TYPES.CHANGE_START_INDEX, start)
|
||||
commit(MUTATION_TYPES.CHANGE_MATCH_WORD, word)
|
||||
commit(MUTATION_TYPES.FILTERED_SUGGESTION_FROM_HASHTAGS)
|
||||
resolve(matched)
|
||||
})
|
||||
win.ipcRenderer.send('get-cache-hashtags')
|
||||
})
|
||||
return matched
|
||||
}
|
||||
const searchAPI = async () => {
|
||||
const client = generator(
|
||||
|
|
Loading…
Reference in New Issue