Mark all calls read when opening calls tab

This commit is contained in:
Jamie Kyle
2023-08-22 14:01:36 -07:00
committed by GitHub
parent b7c17212c7
commit 344ebf494d
8 changed files with 80 additions and 17 deletions

View File

@@ -13,6 +13,7 @@ import { ToastType } from '../../types/Toast';
import type { CallHistoryDetails } from '../../types/CallDisposition';
import * as log from '../../logging/log';
import * as Errors from '../../types/errors';
import { drop } from '../../util/drop';
export type CallHistoryState = ReadonlyDeep<{
// This informs the app that underlying call history data has changed.
@@ -77,9 +78,35 @@ function markCallHistoryRead(
return async dispatch => {
try {
await window.Signal.Data.markCallHistoryRead(callId);
await window.ConversationController.get(conversationId)?.updateUnread();
drop(window.ConversationController.get(conversationId)?.updateUnread());
} catch (error) {
log.error('Error marking call history read', Errors.toLogFormat(error));
log.error(
'markCallHistoryRead: Error marking call history read',
Errors.toLogFormat(error)
);
} finally {
dispatch(updateCallHistoryUnreadCount());
}
};
}
function markCallsTabViewed(): ThunkAction<
void,
RootStateType,
unknown,
CallHistoryUpdateUnread
> {
return async dispatch => {
try {
const conversationIds = await window.Signal.Data.markAllCallHistoryRead();
for (const conversationId of conversationIds) {
drop(window.ConversationController.get(conversationId)?.updateUnread());
}
} catch (error) {
log.error(
'markCallsTabViewed: Error marking all call history read',
Errors.toLogFormat(error)
);
} finally {
dispatch(updateCallHistoryUnreadCount());
}
@@ -118,6 +145,7 @@ export const actions = {
clearAllCallHistory,
updateCallHistoryUnreadCount,
markCallHistoryRead,
markCallsTabViewed,
};
export const useCallHistoryActions = (): BoundActionCreatorsMapObject<

View File

@@ -1,7 +1,7 @@
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useCallback } from 'react';
import React, { useCallback, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { useItemsActions } from '../ducks/items';
import {
@@ -102,8 +102,11 @@ export function SmartCallsTab(): JSX.Element {
onOutgoingAudioCallInConversation,
onOutgoingVideoCallInConversation,
} = useCallingActions();
const { clearAllCallHistory: clearCallHistory, markCallHistoryRead } =
useCallHistoryActions();
const {
clearAllCallHistory: clearCallHistory,
markCallHistoryRead,
markCallsTabViewed,
} = useCallHistoryActions();
const getCallHistoryGroupsCount = useCallback(
async (options: CallHistoryFilterOptions) => {
@@ -149,6 +152,10 @@ export function SmartCallsTab(): JSX.Element {
[allConversations, regionCode, callHistoryEdition]
);
useEffect(() => {
markCallsTabViewed();
}, [markCallsTabViewed]);
return (
<CallsTab
activeCall={activeCall}