fix: in clearinbox check in memory for conversation instead of db lookup

this is more performent
pull/2660/head
William Grant 3 years ago
parent ab04e9bd17
commit c33e471bfc

@ -1,5 +1,4 @@
import AbortController from 'abort-controller'; import AbortController from 'abort-controller';
import { Data } from '../../../../data/data';
import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil'; import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil';
import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils'; import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils';
import { import {
@ -8,6 +7,7 @@ import {
OpenGroupBatchRow, OpenGroupBatchRow,
sogsBatchSend, sogsBatchSend,
} from './sogsV3BatchPoll'; } from './sogsV3BatchPoll';
import { getConversationController } from '../../../conversations';
type OpenGroupClearInboxResponse = { type OpenGroupClearInboxResponse = {
deleted: number; deleted: number;
@ -17,10 +17,10 @@ export const clearInbox = async (roomInfos: OpenGroupRequestCommonType): Promise
let success = false; let success = false;
const conversationId = getOpenGroupV2ConversationId(roomInfos.serverUrl, roomInfos.roomId); const conversationId = getOpenGroupV2ConversationId(roomInfos.serverUrl, roomInfos.roomId);
const conversation = await Data.getConversationById(conversationId); const conversation = getConversationController().get(conversationId);
if (!conversation) { if (!conversation) {
window.log.warn('clearInbox Matching conversation not found in db'); throw new Error(`clearInbox Matching conversation not found in db ${conversationId}`);
} else { } else {
const options: Array<OpenGroupBatchRow> = [ const options: Array<OpenGroupBatchRow> = [
{ {

Loading…
Cancel
Save