Fix update call unread count debounce bound action
This commit is contained in:
parent
187d80066e
commit
0f071afaf2
1 changed files with 17 additions and 13 deletions
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import type { ReadonlyDeep } from 'type-fest';
|
import type { ReadonlyDeep } from 'type-fest';
|
||||||
import type { ThunkAction } from 'redux-thunk';
|
import type { ThunkAction, ThunkDispatch } from 'redux-thunk';
|
||||||
import { debounce, omit } from 'lodash';
|
import { debounce, omit } from 'lodash';
|
||||||
import type { StateType as RootStateType } from '../reducer';
|
import type { StateType as RootStateType } from '../reducer';
|
||||||
import {
|
import {
|
||||||
|
@ -86,13 +86,10 @@ export function getEmptyState(): CallHistoryState {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCallHistoryUnreadCountInner(): ThunkAction<
|
const updateCallHistoryUnreadCountDebounced = debounce(
|
||||||
void,
|
async (
|
||||||
RootStateType,
|
dispatch: ThunkDispatch<RootStateType, unknown, CallHistoryUpdateUnread>
|
||||||
unknown,
|
) => {
|
||||||
CallHistoryUpdateUnread
|
|
||||||
> {
|
|
||||||
return async dispatch => {
|
|
||||||
try {
|
try {
|
||||||
const unreadCount = await DataReader.getCallHistoryUnreadCount();
|
const unreadCount = await DataReader.getCallHistoryUnreadCount();
|
||||||
dispatch({ type: CALL_HISTORY_UPDATE_UNREAD, payload: unreadCount });
|
dispatch({ type: CALL_HISTORY_UPDATE_UNREAD, payload: unreadCount });
|
||||||
|
@ -102,14 +99,21 @@ function updateCallHistoryUnreadCountInner(): ThunkAction<
|
||||||
Errors.toLogFormat(error)
|
Errors.toLogFormat(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
}
|
|
||||||
|
|
||||||
const updateCallHistoryUnreadCount = debounce(
|
|
||||||
updateCallHistoryUnreadCountInner,
|
|
||||||
300
|
300
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function updateCallHistoryUnreadCount(): ThunkAction<
|
||||||
|
void,
|
||||||
|
RootStateType,
|
||||||
|
unknown,
|
||||||
|
CallHistoryUpdateUnread
|
||||||
|
> {
|
||||||
|
return async dispatch => {
|
||||||
|
await updateCallHistoryUnreadCountDebounced(dispatch);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function markCallHistoryRead(
|
function markCallHistoryRead(
|
||||||
conversationId: string,
|
conversationId: string,
|
||||||
callId: string
|
callId: string
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue