chore: remove isGroup from the redux stored entry

as it is always = !isPrivate
pull/2620/head
Audric Ackermann 2 years ago
parent f3975b545a
commit 3ff7281b6a

@ -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) {

@ -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');
}

@ -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

@ -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) {

@ -285,14 +285,13 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
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<ConversationAttributes> {
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<ConversationAttributes> {
toRet.isPrivate = true;
}
if (isGroup) {
toRet.isGroup = true;
}
if (weAreAdmin) {
toRet.weAreAdmin = true;
}

@ -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}

@ -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;

@ -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: '',

Loading…
Cancel
Save