diff --git a/src/main/index.ts b/src/main/index.ts index 9820fb3b..b5cf3d6f 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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) => { diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts index 48101245..13056665 100644 --- a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts +++ b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts @@ -197,21 +197,17 @@ const actions: ActionTree = { commit(MUTATION_TYPES.CLEAR_FILTERED_HASHTAGS) commit(MUTATION_TYPES.FILTERED_SUGGESTION_FROM_HASHTAGS) const { word, start } = wordStart - const searchCache = () => { - return new Promise(resolve => { - const target = word.replace('#', '') - win.ipcRenderer.once('response-get-cache-hashtags', (_, tags: Array) => { - 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) - commit(MUTATION_TYPES.CHANGE_OPEN_SUGGEST, true) - 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') - }) + const searchCache = async () => { + const target = word.replace('#', '') + const tags: Array = 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) + commit(MUTATION_TYPES.CHANGE_OPEN_SUGGEST, true) + commit(MUTATION_TYPES.CHANGE_START_INDEX, start) + commit(MUTATION_TYPES.CHANGE_MATCH_WORD, word) + commit(MUTATION_TYPES.FILTERED_SUGGESTION_FROM_HASHTAGS) + return matched } const searchAPI = async () => { const client = generator(