Backups: Handle groupV2 notifications
This commit is contained in:
parent
4c4ab306eb
commit
5df8924197
27 changed files with 4563 additions and 301 deletions
|
@ -862,23 +862,23 @@ export const getCachedSelectorForConversation = createSelector(
|
|||
}
|
||||
);
|
||||
|
||||
export type GetConversationByIdType = (id?: string) => ConversationType;
|
||||
export const getConversationSelector = createSelector(
|
||||
getCachedSelectorForConversation,
|
||||
export type GetConversationByAnyIdSelectorType = (
|
||||
id?: string
|
||||
) => ConversationType | undefined;
|
||||
export const getConversationByAnyIdSelector = createSelector(
|
||||
getConversationLookup,
|
||||
getConversationsByServiceId,
|
||||
getConversationsByE164,
|
||||
getConversationsByGroupId,
|
||||
(
|
||||
selector: CachedConversationSelectorType,
|
||||
byId: ConversationLookupType,
|
||||
byServiceId: ConversationLookupType,
|
||||
byE164: ConversationLookupType,
|
||||
byGroupId: ConversationLookupType
|
||||
): GetConversationByIdType => {
|
||||
): GetConversationByAnyIdSelectorType => {
|
||||
return (id?: string) => {
|
||||
if (!id) {
|
||||
return selector(undefined);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const onServiceId = getOwn(
|
||||
|
@ -886,19 +886,42 @@ export const getConversationSelector = createSelector(
|
|||
normalizeServiceId(id, 'getConversationSelector')
|
||||
);
|
||||
if (onServiceId) {
|
||||
return selector(onServiceId);
|
||||
return onServiceId;
|
||||
}
|
||||
const onE164 = getOwn(byE164, id);
|
||||
if (onE164) {
|
||||
return selector(onE164);
|
||||
return onE164;
|
||||
}
|
||||
const onGroupId = getOwn(byGroupId, id);
|
||||
if (onGroupId) {
|
||||
return selector(onGroupId);
|
||||
return onGroupId;
|
||||
}
|
||||
const onId = getOwn(byId, id);
|
||||
if (onId) {
|
||||
return selector(onId);
|
||||
return onId;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
export type GetConversationByIdType = (id?: string) => ConversationType;
|
||||
export const getConversationSelector = createSelector(
|
||||
getCachedSelectorForConversation,
|
||||
getConversationByAnyIdSelector,
|
||||
(
|
||||
selector: CachedConversationSelectorType,
|
||||
getById: GetConversationByAnyIdSelectorType
|
||||
): GetConversationByIdType => {
|
||||
return (id?: string) => {
|
||||
if (!id) {
|
||||
return selector(undefined);
|
||||
}
|
||||
|
||||
const byId = getById(id);
|
||||
if (byId) {
|
||||
return selector(byId);
|
||||
}
|
||||
|
||||
log.warn(`getConversationSelector: No conversation found for id ${id}`);
|
||||
|
@ -908,6 +931,24 @@ export const getConversationSelector = createSelector(
|
|||
}
|
||||
);
|
||||
|
||||
export type CheckServiceIdEquivalenceType = (
|
||||
left: ServiceIdString | undefined,
|
||||
right: ServiceIdString | undefined
|
||||
) => boolean;
|
||||
export const getCheckServiceIdEquivalence = createSelector(
|
||||
getConversationByAnyIdSelector,
|
||||
(
|
||||
getById: GetConversationByAnyIdSelectorType
|
||||
): CheckServiceIdEquivalenceType => {
|
||||
return (
|
||||
left: ServiceIdString | undefined,
|
||||
right: ServiceIdString | undefined
|
||||
): boolean => {
|
||||
return Boolean(left && right && getById(left) === getById(right));
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
export const getConversationByIdSelector = createSelector(
|
||||
getConversationLookup,
|
||||
conversationLookup =>
|
||||
|
|
|
@ -1113,6 +1113,8 @@ function getPropsForGroupV1Migration(
|
|||
conversationId: message.conversationId,
|
||||
droppedMembers,
|
||||
invitedMembers,
|
||||
droppedMemberCount: droppedMembers.length,
|
||||
invitedMemberCount: invitedMembers.length,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1120,19 +1122,30 @@ function getPropsForGroupV1Migration(
|
|||
areWeInvited,
|
||||
droppedMemberIds,
|
||||
invitedMembers: rawInvitedMembers,
|
||||
droppedMemberCount: rawDroppedMemberCount,
|
||||
invitedMemberCount: rawInvitedMemberCount,
|
||||
} = migration;
|
||||
const invitedMembers = rawInvitedMembers.map(item =>
|
||||
conversationSelector(item.uuid)
|
||||
);
|
||||
const droppedMembers = droppedMemberIds.map(conversationId =>
|
||||
conversationSelector(conversationId)
|
||||
);
|
||||
const droppedMembers = droppedMemberIds
|
||||
? droppedMemberIds.map(conversationId =>
|
||||
conversationSelector(conversationId)
|
||||
)
|
||||
: undefined;
|
||||
const invitedMembers = rawInvitedMembers
|
||||
? rawInvitedMembers.map(item => conversationSelector(item.uuid))
|
||||
: undefined;
|
||||
|
||||
const droppedMemberCount =
|
||||
rawDroppedMemberCount ?? droppedMemberIds?.length ?? 0;
|
||||
const invitedMemberCount =
|
||||
rawInvitedMemberCount ?? invitedMembers?.length ?? 0;
|
||||
|
||||
return {
|
||||
areWeInvited,
|
||||
conversationId: message.conversationId,
|
||||
droppedMembers,
|
||||
invitedMembers,
|
||||
droppedMemberCount,
|
||||
invitedMemberCount,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,9 @@ export const SmartGroupV1MigrationDialog = memo(
|
|||
hasMigrated={hasMigrated}
|
||||
getPreferredBadge={getPreferredBadge}
|
||||
droppedMembers={droppedMembers}
|
||||
droppedMemberCount={droppedMembers.length}
|
||||
invitedMembers={invitedMembers}
|
||||
invitedMemberCount={invitedMembers.length}
|
||||
onMigrate={handleMigrate}
|
||||
onClose={closeGV2MigrationDialog}
|
||||
/>
|
||||
|
|
|
@ -21,7 +21,10 @@ import {
|
|||
getTheme,
|
||||
getPlatform,
|
||||
} from '../selectors/user';
|
||||
import { getTargetedMessage } from '../selectors/conversations';
|
||||
import {
|
||||
getTargetedMessage,
|
||||
getCheckServiceIdEquivalence,
|
||||
} from '../selectors/conversations';
|
||||
import { useTimelineItem } from '../selectors/timeline';
|
||||
import {
|
||||
areMessagesInSameGroup,
|
||||
|
@ -86,6 +89,7 @@ export const SmartTimelineItem = memo(function SmartTimelineItem(
|
|||
const isTargeted = Boolean(
|
||||
targetedMessage && messageId === targetedMessage.id
|
||||
);
|
||||
const checkServiceIdEquivalence = useSelector(getCheckServiceIdEquivalence);
|
||||
|
||||
const isNextItemCallingNotification = nextItem?.type === 'callHistory';
|
||||
|
||||
|
@ -176,6 +180,7 @@ export const SmartTimelineItem = memo(function SmartTimelineItem(
|
|||
<TimelineItem
|
||||
item={item}
|
||||
id={messageId}
|
||||
checkServiceIdEquivalence={checkServiceIdEquivalence}
|
||||
containerElementRef={containerElementRef}
|
||||
containerWidthBreakpoint={containerWidthBreakpoint}
|
||||
conversationId={conversationId}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue