2023-08-09 00:53:06 +00:00
|
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-07-22 18:16:33 +00:00
|
|
|
import { DataReader, DataWriter } from '../sql/Client';
|
2023-08-09 00:53:06 +00:00
|
|
|
import type { CallHistoryDetails } from '../types/CallDisposition';
|
|
|
|
import { strictAssert } from '../util/assert';
|
|
|
|
|
|
|
|
let callsHistoryData: ReadonlyArray<CallHistoryDetails>;
|
2024-03-04 22:26:49 +00:00
|
|
|
let callsHistoryUnreadCount: number;
|
2023-08-09 00:53:06 +00:00
|
|
|
|
2024-08-26 14:26:21 +00:00
|
|
|
export async function loadCallHistory(): Promise<void> {
|
2024-07-22 18:16:33 +00:00
|
|
|
await DataWriter.cleanupCallHistoryMessages();
|
|
|
|
callsHistoryData = await DataReader.getAllCallHistory();
|
|
|
|
callsHistoryUnreadCount = await DataReader.getCallHistoryUnreadCount();
|
2023-08-09 00:53:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getCallsHistoryForRedux(): ReadonlyArray<CallHistoryDetails> {
|
|
|
|
strictAssert(callsHistoryData != null, 'callHistory has not been loaded');
|
|
|
|
return callsHistoryData;
|
|
|
|
}
|
2024-03-04 22:26:49 +00:00
|
|
|
|
|
|
|
export function getCallsHistoryUnreadCountForRedux(): number {
|
|
|
|
strictAssert(
|
|
|
|
callsHistoryUnreadCount != null,
|
|
|
|
'callHistory has not been loaded'
|
|
|
|
);
|
|
|
|
return callsHistoryUnreadCount;
|
|
|
|
}
|