diff --git a/ts/components/dialog/InviteContactsDialog.tsx b/ts/components/dialog/InviteContactsDialog.tsx index 8aad39239..795e60fd7 100644 --- a/ts/components/dialog/InviteContactsDialog.tsx +++ b/ts/components/dialog/InviteContactsDialog.tsx @@ -111,7 +111,7 @@ const InviteContactsDialogInner = (props: Props) => { if (!convoProps) { throw new Error('InviteContactsDialogInner not a valid convoId given'); } - if (!convoProps.isGroup) { + if (convoProps.isPrivate) { throw new Error('InviteContactsDialogInner must be a group'); } if (!convoProps.isPublic) { diff --git a/ts/components/dialog/UpdateGroupMembersDialog.tsx b/ts/components/dialog/UpdateGroupMembersDialog.tsx index 6b6958358..b6e59d3c8 100644 --- a/ts/components/dialog/UpdateGroupMembersDialog.tsx +++ b/ts/components/dialog/UpdateGroupMembersDialog.tsx @@ -177,7 +177,7 @@ export const UpdateGroupMembersDialog = (props: Props) => { const dispatch = useDispatch(); - if (!convoProps || !convoProps.isGroup || convoProps.isPublic) { + if (!convoProps || convoProps.isPrivate || convoProps.isPublic) { throw new Error('UpdateGroupMembersDialog invalid convoProps'); } diff --git a/ts/hooks/useMembersAvatars.tsx b/ts/hooks/useMembersAvatars.tsx index 1967381f6..4daa649d5 100644 --- a/ts/hooks/useMembersAvatars.tsx +++ b/ts/hooks/useMembersAvatars.tsx @@ -12,7 +12,7 @@ export function useMembersAvatars(closedGroupPubkey: string | undefined) { } const groupConvo = state.conversations.conversationLookup[closedGroupPubkey]; - if (groupConvo.isPrivate || groupConvo.isPublic || !groupConvo.isGroup) { + if (groupConvo.isPrivate || groupConvo.isPublic) { return undefined; } // this must be a closed group diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index 1c2f23642..a9a95bf9c 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -71,7 +71,7 @@ export function useIsMe(pubkey?: string) { export function useIsClosedGroup(convoId?: string) { const convoProps = useConversationPropsById(convoId); - return (convoProps && convoProps.isGroup && !convoProps.isPublic) || false; + return (convoProps && !convoProps.isPrivate && !convoProps.isPublic) || false; } export function useIsPrivate(convoId?: string) { diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index f32f0cadd..501b41854 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -285,14 +285,13 @@ export class ConversationModel extends Backbone.Model { const ourNumber = UserUtils.getOurPubKeyStrFromCache(); const avatarPath = this.getAvatarPath(); const isPrivate = this.isPrivate(); - const isGroup = !isPrivate; const weAreAdmin = this.isAdmin(ourNumber); const weAreModerator = this.isModerator(ourNumber); // only used for sogs const isMe = this.isMe(); const isTyping = !!this.typingTimer; const currentNotificationSetting = this.get('triggerNotificationsFor'); - const priority = this.get('priority'); + const priorityFromDb = this.get('priority'); // To reduce the redux store size, only set fields which cannot be undefined. // For instance, a boolean can usually be not set if false, etc @@ -302,8 +301,8 @@ export class ConversationModel extends Backbone.Model { type: this.get('type'), }; - if (isFinite(priority) && priority !== CONVERSATION_PRIORITIES.default) { - toRet.priority = priority; + if (isFinite(priorityFromDb) && priorityFromDb !== CONVERSATION_PRIORITIES.default) { + toRet.priority = priorityFromDb; } if (this.get('markedAsUnread')) { @@ -314,10 +313,6 @@ export class ConversationModel extends Backbone.Model { toRet.isPrivate = true; } - if (isGroup) { - toRet.isGroup = true; - } - if (weAreAdmin) { toRet.weAreAdmin = true; } diff --git a/ts/node/migration/sessionMigrations.ts b/ts/node/migration/sessionMigrations.ts index 5b303f59a..e9181f48f 100644 --- a/ts/node/migration/sessionMigrations.ts +++ b/ts/node/migration/sessionMigrations.ts @@ -1463,8 +1463,9 @@ function updateToSessionSchemaVersion30(currentVersion: number, db: BetterSqlite ALTER TABLE unprocessed DROP COLUMN serverTimestamp; `); - // after the rename of isPinned to priority, we also need to hide any conversation that - // TODO do we need to update the conversation priority to hidden for some for those ( like the non active and non approved/didApproveMe?) + // after the rename of isPinned to priority, we also need to hide any private conversation that is not active at all. + // as they might be contacts, we did delete from the app already. + db.prepare( `UPDATE ${CONVERSATIONS_TABLE} SET priority = ${CONVERSATION_PRIORITIES.hidden} diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 41cea8176..364261ebd 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -234,8 +234,7 @@ export interface ReduxConversationType { type: ConversationTypeEnum; isMe?: boolean; isPublic?: boolean; - isGroup?: boolean; - isPrivate?: boolean; + isPrivate?: boolean; // !isPrivate means isGroup (group or community) weAreAdmin?: boolean; weAreModerator?: boolean; unreadCount?: number; diff --git a/ts/test/session/unit/selectors/conversations_test.ts b/ts/test/session/unit/selectors/conversations_test.ts index 97bb83e77..e51606c9a 100644 --- a/ts/test/session/unit/selectors/conversations_test.ts +++ b/ts/test/session/unit/selectors/conversations_test.ts @@ -32,7 +32,6 @@ describe('state/selectors/conversations', () => { isPublic: false, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '', @@ -58,7 +57,6 @@ describe('state/selectors/conversations', () => { isPublic: false, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '', groupAdmins: [], @@ -83,7 +81,6 @@ describe('state/selectors/conversations', () => { isPublic: false, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '', groupAdmins: [], @@ -108,9 +105,7 @@ describe('state/selectors/conversations', () => { isPublic: false, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, - avatarPath: '', groupAdmins: [], expireTimer: 0, @@ -135,7 +130,6 @@ describe('state/selectors/conversations', () => { expireTimer: 0, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '', @@ -177,7 +171,6 @@ describe('state/selectors/conversations', () => { expireTimer: 0, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '', @@ -204,7 +197,6 @@ describe('state/selectors/conversations', () => { expireTimer: 0, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '', @@ -231,7 +223,6 @@ describe('state/selectors/conversations', () => { expireTimer: 0, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, displayNameInProfile: 'C', @@ -258,7 +249,6 @@ describe('state/selectors/conversations', () => { expireTimer: 0, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '', @@ -285,7 +275,6 @@ describe('state/selectors/conversations', () => { expireTimer: 0, currentNotificationSetting: 'all', weAreAdmin: false, - isGroup: false, isPrivate: false, avatarPath: '',