Fix calls tab clearing clicking on old calls
This commit is contained in:
parent
c3248be854
commit
55dca745c7
5 changed files with 40 additions and 11 deletions
|
@ -111,6 +111,7 @@ type CallsListProps = Readonly<{
|
||||||
options: CallHistoryFilterOptions,
|
options: CallHistoryFilterOptions,
|
||||||
pagination: CallHistoryPagination
|
pagination: CallHistoryPagination
|
||||||
) => Promise<Array<CallHistoryGroup>>;
|
) => Promise<Array<CallHistoryGroup>>;
|
||||||
|
callHistoryEdition: number;
|
||||||
getConversation: (id: string) => ConversationType | void;
|
getConversation: (id: string) => ConversationType | void;
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
selectedCallHistoryGroup: CallHistoryGroup | null;
|
selectedCallHistoryGroup: CallHistoryGroup | null;
|
||||||
|
@ -139,6 +140,7 @@ export function CallsList({
|
||||||
hasActiveCall,
|
hasActiveCall,
|
||||||
getCallHistoryGroupsCount,
|
getCallHistoryGroupsCount,
|
||||||
getCallHistoryGroups,
|
getCallHistoryGroups,
|
||||||
|
callHistoryEdition,
|
||||||
getConversation,
|
getConversation,
|
||||||
i18n,
|
i18n,
|
||||||
selectedCallHistoryGroup,
|
selectedCallHistoryGroup,
|
||||||
|
@ -154,6 +156,14 @@ export function CallsList({
|
||||||
|
|
||||||
const prevOptionsRef = useRef<CallHistoryFilterOptions | null>(null);
|
const prevOptionsRef = useRef<CallHistoryFilterOptions | null>(null);
|
||||||
|
|
||||||
|
const getCallHistoryGroupsCountRef = useRef(getCallHistoryGroupsCount);
|
||||||
|
const getCallHistoryGroupsRef = useRef(getCallHistoryGroups);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getCallHistoryGroupsCountRef.current = getCallHistoryGroupsCount;
|
||||||
|
getCallHistoryGroupsRef.current = getCallHistoryGroups;
|
||||||
|
}, [getCallHistoryGroupsCount, getCallHistoryGroups]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
@ -180,8 +190,8 @@ export function CallsList({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [count, items] = await Promise.all([
|
const [count, items] = await Promise.all([
|
||||||
getCallHistoryGroupsCount(options),
|
getCallHistoryGroupsCountRef.current(options),
|
||||||
getCallHistoryGroups(options, {
|
getCallHistoryGroupsRef.current(options, {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 100, // preloaded rows
|
limit: 100, // preloaded rows
|
||||||
}),
|
}),
|
||||||
|
@ -226,7 +236,7 @@ export function CallsList({
|
||||||
return () => {
|
return () => {
|
||||||
controller.abort();
|
controller.abort();
|
||||||
};
|
};
|
||||||
}, [getCallHistoryGroupsCount, getCallHistoryGroups, queryInput, status]);
|
}, [queryInput, status, callHistoryEdition]);
|
||||||
|
|
||||||
const loadMoreRows = useCallback(
|
const loadMoreRows = useCallback(
|
||||||
async (props: IndexRange) => {
|
async (props: IndexRange) => {
|
||||||
|
@ -250,7 +260,10 @@ export function CallsList({
|
||||||
const limit = stopIndex - startIndex + 1;
|
const limit = stopIndex - startIndex + 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const groups = await getCallHistoryGroups(options, { offset, limit });
|
const groups = await getCallHistoryGroupsRef.current(options, {
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
});
|
||||||
|
|
||||||
if (searchState.options !== options) {
|
if (searchState.options !== options) {
|
||||||
return;
|
return;
|
||||||
|
@ -275,7 +288,7 @@ export function CallsList({
|
||||||
log.error('CallsList#loadMoreRows error fetching', error);
|
log.error('CallsList#loadMoreRows error fetching', error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[getCallHistoryGroups, searchState]
|
[searchState]
|
||||||
);
|
);
|
||||||
|
|
||||||
const isRowLoaded = useCallback(
|
const isRowLoaded = useCallback(
|
||||||
|
|
|
@ -34,6 +34,7 @@ type CallsTabProps = Readonly<{
|
||||||
options: CallHistoryFilterOptions,
|
options: CallHistoryFilterOptions,
|
||||||
pagination: CallHistoryPagination
|
pagination: CallHistoryPagination
|
||||||
) => Promise<Array<CallHistoryGroup>>;
|
) => Promise<Array<CallHistoryGroup>>;
|
||||||
|
callHistoryEdition: number;
|
||||||
getConversation: (id: string) => ConversationType | void;
|
getConversation: (id: string) => ConversationType | void;
|
||||||
hasFailedStorySends: boolean;
|
hasFailedStorySends: boolean;
|
||||||
hasPendingUpdate: boolean;
|
hasPendingUpdate: boolean;
|
||||||
|
@ -59,6 +60,7 @@ export function CallsTab({
|
||||||
otherTabsUnreadStats,
|
otherTabsUnreadStats,
|
||||||
getCallHistoryGroupsCount,
|
getCallHistoryGroupsCount,
|
||||||
getCallHistoryGroups,
|
getCallHistoryGroups,
|
||||||
|
callHistoryEdition,
|
||||||
getConversation,
|
getConversation,
|
||||||
hasFailedStorySends,
|
hasFailedStorySends,
|
||||||
hasPendingUpdate,
|
hasPendingUpdate,
|
||||||
|
@ -221,6 +223,7 @@ export function CallsTab({
|
||||||
hasActiveCall={activeCall != null}
|
hasActiveCall={activeCall != null}
|
||||||
getCallHistoryGroupsCount={getCallHistoryGroupsCount}
|
getCallHistoryGroupsCount={getCallHistoryGroupsCount}
|
||||||
getCallHistoryGroups={getCallHistoryGroups}
|
getCallHistoryGroups={getCallHistoryGroups}
|
||||||
|
callHistoryEdition={callHistoryEdition}
|
||||||
getConversation={getConversation}
|
getConversation={getConversation}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
selectedCallHistoryGroup={selected?.callHistoryGroup ?? null}
|
selectedCallHistoryGroup={selected?.callHistoryGroup ?? null}
|
||||||
|
|
|
@ -187,6 +187,7 @@ export function reducer(
|
||||||
case CALL_HISTORY_ADD:
|
case CALL_HISTORY_ADD:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
edition: state.edition + 1,
|
||||||
callHistoryByCallId: {
|
callHistoryByCallId: {
|
||||||
...state.callHistoryByCallId,
|
...state.callHistoryByCallId,
|
||||||
[action.payload.callId]: action.payload,
|
[action.payload.callId]: action.payload,
|
||||||
|
@ -195,6 +196,7 @@ export function reducer(
|
||||||
case CALL_HISTORY_REMOVE:
|
case CALL_HISTORY_REMOVE:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
edition: state.edition + 1,
|
||||||
callHistoryByCallId: omit(state.callHistoryByCallId, action.payload),
|
callHistoryByCallId: omit(state.callHistoryByCallId, action.payload),
|
||||||
};
|
};
|
||||||
case CALL_HISTORY_UPDATE_UNREAD:
|
case CALL_HISTORY_UPDATE_UNREAD:
|
||||||
|
|
|
@ -110,8 +110,6 @@ export function SmartCallsTab(): JSX.Element {
|
||||||
|
|
||||||
const getCallHistoryGroupsCount = useCallback(
|
const getCallHistoryGroupsCount = useCallback(
|
||||||
async (options: CallHistoryFilterOptions) => {
|
async (options: CallHistoryFilterOptions) => {
|
||||||
// Used to fire effects when all calls are erased
|
|
||||||
void callHistoryEdition;
|
|
||||||
const callHistoryFilter = getCallHistoryFilter(
|
const callHistoryFilter = getCallHistoryFilter(
|
||||||
allConversations,
|
allConversations,
|
||||||
regionCode,
|
regionCode,
|
||||||
|
@ -125,7 +123,7 @@ export function SmartCallsTab(): JSX.Element {
|
||||||
);
|
);
|
||||||
return count;
|
return count;
|
||||||
},
|
},
|
||||||
[allConversations, regionCode, callHistoryEdition]
|
[allConversations, regionCode]
|
||||||
);
|
);
|
||||||
|
|
||||||
const getCallHistoryGroups = useCallback(
|
const getCallHistoryGroups = useCallback(
|
||||||
|
@ -133,8 +131,6 @@ export function SmartCallsTab(): JSX.Element {
|
||||||
options: CallHistoryFilterOptions,
|
options: CallHistoryFilterOptions,
|
||||||
pagination: CallHistoryPagination
|
pagination: CallHistoryPagination
|
||||||
) => {
|
) => {
|
||||||
// Used to fire effects when all calls are erased
|
|
||||||
void callHistoryEdition;
|
|
||||||
const callHistoryFilter = getCallHistoryFilter(
|
const callHistoryFilter = getCallHistoryFilter(
|
||||||
allConversations,
|
allConversations,
|
||||||
regionCode,
|
regionCode,
|
||||||
|
@ -149,7 +145,7 @@ export function SmartCallsTab(): JSX.Element {
|
||||||
);
|
);
|
||||||
return results;
|
return results;
|
||||||
},
|
},
|
||||||
[allConversations, regionCode, callHistoryEdition]
|
[allConversations, regionCode]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -164,6 +160,7 @@ export function SmartCallsTab(): JSX.Element {
|
||||||
getConversation={getConversation}
|
getConversation={getConversation}
|
||||||
getCallHistoryGroupsCount={getCallHistoryGroupsCount}
|
getCallHistoryGroupsCount={getCallHistoryGroupsCount}
|
||||||
getCallHistoryGroups={getCallHistoryGroups}
|
getCallHistoryGroups={getCallHistoryGroups}
|
||||||
|
callHistoryEdition={callHistoryEdition}
|
||||||
hasFailedStorySends={hasFailedStorySends}
|
hasFailedStorySends={hasFailedStorySends}
|
||||||
hasPendingUpdate={hasPendingUpdate}
|
hasPendingUpdate={hasPendingUpdate}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
|
|
|
@ -3086,6 +3086,20 @@
|
||||||
"reasonCategory": "usageTrusted",
|
"reasonCategory": "usageTrusted",
|
||||||
"updated": "2023-08-18T19:09:30.283Z"
|
"updated": "2023-08-18T19:09:30.283Z"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"rule": "React-useRef",
|
||||||
|
"path": "ts/components/CallsList.tsx",
|
||||||
|
"line": " const getCallHistoryGroupsCountRef = useRef(getCallHistoryGroupsCount);",
|
||||||
|
"reasonCategory": "usageTrusted",
|
||||||
|
"updated": "2023-11-27T20:25:10.634Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rule": "React-useRef",
|
||||||
|
"path": "ts/components/CallsList.tsx",
|
||||||
|
"line": " const getCallHistoryGroupsRef = useRef(getCallHistoryGroups);",
|
||||||
|
"reasonCategory": "usageTrusted",
|
||||||
|
"updated": "2023-11-27T20:25:10.634Z"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"rule": "React-useRef",
|
"rule": "React-useRef",
|
||||||
"path": "ts/components/CaptchaDialog.tsx",
|
"path": "ts/components/CaptchaDialog.tsx",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue