fix: remove isLeft flag as we can't have a left and unremoved group

pull/2963/head
Audric Ackermann 2 years ago
parent 456df58205
commit 4e8ca31c2f

@ -99,6 +99,7 @@
flex-grow: 1; flex-grow: 1;
width: 100%; width: 100%;
height: 0; height: 0;
overflow-y: auto;
background-color: inherit; background-color: inherit;
outline: none; outline: none;
position: relative; position: relative;

@ -489,16 +489,13 @@ class CompositionBoxInner extends React.Component<Props, State> {
if (isKickedFromGroup) { if (isKickedFromGroup) {
return i18n('youGotKickedFromGroup'); return i18n('youGotKickedFromGroup');
} }
if (left) {
return i18n('youLeftTheGroup');
}
if (isBlocked) { if (isBlocked) {
return i18n('unblockToSend'); return i18n('unblockToSend');
} }
return i18n('sendMessage'); return i18n('sendMessage');
}; };
const { isKickedFromGroup, left, isBlocked } = this.props.selectedConversation; const { isKickedFromGroup, isBlocked } = this.props.selectedConversation;
const messagePlaceHolder = makeMessagePlaceHolderText(); const messagePlaceHolder = makeMessagePlaceHolderText();
const neverMatchingRegex = /($a)/; const neverMatchingRegex = /($a)/;
@ -932,10 +929,6 @@ class CompositionBoxInner extends React.Component<Props, State> {
return; return;
} }
if (!selectedConversation.isPrivate && selectedConversation.left) {
ToastUtils.pushYouLeftTheGroup();
return;
}
if (!selectedConversation.isPrivate && selectedConversation.isKickedFromGroup) { if (!selectedConversation.isPrivate && selectedConversation.isKickedFromGroup) {
ToastUtils.pushYouLeftTheGroup(); ToastUtils.pushYouLeftTheGroup();
return; return;

@ -27,7 +27,6 @@ import {
useSelectedIsBlocked, useSelectedIsBlocked,
useSelectedIsGroup, useSelectedIsGroup,
useSelectedIsKickedFromGroup, useSelectedIsKickedFromGroup,
useSelectedIsLeft,
useSelectedIsPublic, useSelectedIsPublic,
useSelectedSubscriberCount, useSelectedSubscriberCount,
useSelectedWeAreAdmin, useSelectedWeAreAdmin,
@ -117,14 +116,13 @@ const HeaderItem = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const isBlocked = useSelectedIsBlocked(); const isBlocked = useSelectedIsBlocked();
const isKickedFromGroup = useSelectedIsKickedFromGroup(); const isKickedFromGroup = useSelectedIsKickedFromGroup();
const left = useSelectedIsLeft();
const isGroup = useSelectedIsGroup(); const isGroup = useSelectedIsGroup();
if (!selectedConvoKey) { if (!selectedConvoKey) {
return null; return null;
} }
const showInviteContacts = isGroup && !isKickedFromGroup && !isBlocked && !left; const showInviteContacts = isGroup && !isKickedFromGroup && !isBlocked;
return ( return (
<div className="right-panel-header"> <div className="right-panel-header">
@ -212,7 +210,6 @@ export const OverlayRightPanelSettings = () => {
const displayNameInProfile = useSelectedDisplayNameInProfile(); const displayNameInProfile = useSelectedDisplayNameInProfile();
const isBlocked = useSelectedIsBlocked(); const isBlocked = useSelectedIsBlocked();
const isKickedFromGroup = useSelectedIsKickedFromGroup(); const isKickedFromGroup = useSelectedIsKickedFromGroup();
const left = useSelectedIsLeft();
const isGroup = useSelectedIsGroup(); const isGroup = useSelectedIsGroup();
const isPublic = useSelectedIsPublic(); const isPublic = useSelectedIsPublic();
const weAreAdmin = useSelectedWeAreAdmin(); const weAreAdmin = useSelectedWeAreAdmin();
@ -264,15 +261,13 @@ export const OverlayRightPanelSettings = () => {
} }
const showMemberCount = !!(subscriberCount && subscriberCount > 0); const showMemberCount = !!(subscriberCount && subscriberCount > 0);
const commonNoShow = isKickedFromGroup || left || isBlocked || !isActive; const commonNoShow = isKickedFromGroup || isBlocked || !isActive;
const hasDisappearingMessages = !isPublic && !commonNoShow; const hasDisappearingMessages = !isPublic && !commonNoShow;
const leaveGroupString = isPublic const leaveGroupString = isPublic
? window.i18n('leaveGroup') ? window.i18n('leaveGroup')
: isKickedFromGroup : isKickedFromGroup
? window.i18n('youGotKickedFromGroup') ? window.i18n('youGotKickedFromGroup')
: left : window.i18n('leaveGroup');
? window.i18n('youLeftTheGroup')
: window.i18n('leaveGroup');
const showUpdateGroupNameButton = isGroup && weAreAdmin && !commonNoShow; // legacy groups non-admin cannot change groupname anymore const showUpdateGroupNameButton = isGroup && weAreAdmin && !commonNoShow; // legacy groups non-admin cannot change groupname anymore
const showAddRemoveModeratorsButton = weAreAdmin && !commonNoShow && isPublic; const showAddRemoveModeratorsButton = weAreAdmin && !commonNoShow && isPublic;
@ -369,7 +364,7 @@ export const OverlayRightPanelSettings = () => {
text={leaveGroupString} text={leaveGroupString}
buttonColor={SessionButtonColor.Danger} buttonColor={SessionButtonColor.Danger}
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
disabled={isKickedFromGroup || left} disabled={isKickedFromGroup}
onClick={deleteConvoAction} onClick={deleteConvoAction}
/> />
</StyledLeaveButton> </StyledLeaveButton>

@ -12,7 +12,6 @@ import {
useIsGroupV2, useIsGroupV2,
useIsIncomingRequest, useIsIncomingRequest,
useIsKickedFromGroup, useIsKickedFromGroup,
useIsLeft,
useIsMe, useIsMe,
useIsPrivate, useIsPrivate,
useIsPrivateAndFriend, useIsPrivateAndFriend,
@ -138,14 +137,13 @@ export const DeleteGroupOrCommunityMenuItem = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const convoId = useConvoIdFromContext(); const convoId = useConvoIdFromContext();
const isPublic = useIsPublic(convoId); const isPublic = useIsPublic(convoId);
const isLeft = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId); const isKickedFromGroup = useIsKickedFromGroup(convoId);
const isPrivate = useIsPrivate(convoId); const isPrivate = useIsPrivate(convoId);
const isGroup = !isPrivate && !isPublic; const isGroup = !isPrivate && !isPublic;
// You need to have left a closed group first to be able to delete it completely as there is a leaving message to send first. // You need to have left a closed group first to be able to delete it completely as there is a leaving message to send first.
// A community can just be removed right away. // A community can just be removed right away.
if (isPublic || (isGroup && (isLeft || isKickedFromGroup))) { if (isPublic || (isGroup && isKickedFromGroup)) {
const menuItemText = isPublic ? window.i18n('leaveGroup') : window.i18n('editMenuDeleteGroup'); const menuItemText = isPublic ? window.i18n('leaveGroup') : window.i18n('editMenuDeleteGroup');
const onClickClose = () => { const onClickClose = () => {
@ -183,11 +181,10 @@ export const DeleteGroupOrCommunityMenuItem = () => {
export const LeaveGroupMenuItem = () => { export const LeaveGroupMenuItem = () => {
const convoId = useConvoIdFromContext(); const convoId = useConvoIdFromContext();
const isPublic = useIsPublic(convoId); const isPublic = useIsPublic(convoId);
const isLeft = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId); const isKickedFromGroup = useIsKickedFromGroup(convoId);
const isPrivate = useIsPrivate(convoId); const isPrivate = useIsPrivate(convoId);
if (!isKickedFromGroup && !isLeft && !isPrivate && !isPublic) { if (!isKickedFromGroup && !isPrivate && !isPublic) {
return ( return (
<Item <Item
onClick={() => { onClick={() => {
@ -233,11 +230,10 @@ export const ShowUserDetailsMenuItem = () => {
export const UpdateGroupNameMenuItem = () => { export const UpdateGroupNameMenuItem = () => {
const convoId = useConvoIdFromContext(); const convoId = useConvoIdFromContext();
const left = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId); const isKickedFromGroup = useIsKickedFromGroup(convoId);
const weAreAdmin = useWeAreAdmin(convoId); const weAreAdmin = useWeAreAdmin(convoId);
if (!isKickedFromGroup && !left && weAreAdmin) { if (!isKickedFromGroup && weAreAdmin) {
return ( return (
<Item <Item
onClick={() => { onClick={() => {
@ -562,19 +558,11 @@ export const NotificationForConvoMenuItem = (): JSX.Element | null => {
const currentNotificationSetting = useNotificationSetting(convoId); const currentNotificationSetting = useNotificationSetting(convoId);
const isBlocked = useIsBlocked(convoId); const isBlocked = useIsBlocked(convoId);
const isActive = useIsActive(convoId); const isActive = useIsActive(convoId);
const isLeft = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId); const isKickedFromGroup = useIsKickedFromGroup(convoId);
const isFriend = useIsPrivateAndFriend(convoId); const isFriend = useIsPrivateAndFriend(convoId);
const isPrivate = useIsPrivate(convoId); const isPrivate = useIsPrivate(convoId);
if ( if (!convoId || isKickedFromGroup || isBlocked || !isActive || (isPrivate && !isFriend)) {
!convoId ||
isLeft ||
isKickedFromGroup ||
isBlocked ||
!isActive ||
(isPrivate && !isFriend)
) {
return null; return null;
} }

@ -22,7 +22,7 @@ import {
import { useLibGroupAdmins, useLibGroupMembers, useLibGroupName } from '../state/selectors/groups'; import { useLibGroupAdmins, useLibGroupMembers, useLibGroupName } from '../state/selectors/groups';
import { isPrivateAndFriend } from '../state/selectors/selectedConversation'; import { isPrivateAndFriend } from '../state/selectors/selectedConversation';
import { useOurPkStr } from '../state/selectors/user'; import { useOurPkStr } from '../state/selectors/user';
import { useLibGroupInvitePending } from '../state/selectors/userGroups'; import { useLibGroupInvitePending, useLibGroupKicked } from '../state/selectors/userGroups';
export function useAvatarPath(convoId: string | undefined) { export function useAvatarPath(convoId: string | undefined) {
const convoProps = useConversationPropsById(convoId); const convoProps = useConversationPropsById(convoId);

@ -411,9 +411,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
if (this.isKickedFromGroup()) { if (this.isKickedFromGroup()) {
toRet.isKickedFromGroup = this.isKickedFromGroup(); toRet.isKickedFromGroup = this.isKickedFromGroup();
} }
if (this.isLeft()) {
toRet.left = this.isLeft();
}
// to be dropped once we get rid of the legacy closed groups // to be dropped once we get rid of the legacy closed groups
const zombies = this.getGroupZombies() || []; const zombies = this.getGroupZombies() || [];
if (zombies?.length) { if (zombies?.length) {
@ -1916,24 +1913,13 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
public isKickedFromGroup(): boolean { public isKickedFromGroup(): boolean {
if (this.isClosedGroup()) { if (this.isClosedGroup()) {
if (this.isClosedGroupV2()) { if (this.isClosedGroupV2()) {
// console.info('isKickedFromGroup using lib todo'); // debugger return getLibGroupKickedOutsideRedux(this.id) || false;
} }
return !!this.get('isKickedFromGroup'); return !!this.get('isKickedFromGroup');
} }
return false; return false;
} }
public isLeft(): boolean {
if (this.isClosedGroup()) {
if (this.isClosedGroupV2()) {
// getLibGroupNameOutsideRedux(this.id) ||
// console.info('isLeft using lib todo'); // debugger
}
return !!this.get('left');
}
return false;
}
public getActiveAt(): number | undefined { public getActiveAt(): number | undefined {
return this.get('active_at'); return this.get('active_at');
} }

@ -522,9 +522,6 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
return undefined; return undefined;
} }
if (this.getConversation()?.isLeft()) {
return 'sent';
}
const readBy = this.get('read_by') || []; const readBy = this.get('read_by') || [];
if (Storage.get(SettingsKey.settingsReadReceipt) && readBy.length > 0) { if (Storage.get(SettingsKey.settingsReadReceipt) && readBy.length > 0) {

@ -304,8 +304,8 @@ export async function handleNewClosedGroup(
const expireTimer = groupUpdate.expirationTimer; const expireTimer = groupUpdate.expirationTimer;
if (groupConvo) { if (groupConvo) {
// if we did not left this group, just add the keypair we got if not already there // if we did not got kicked this group, just add the keypair we got if not already there
if (!groupConvo.isKickedFromGroup() && !groupConvo.isLeft()) { if (!groupConvo.isKickedFromGroup()) {
const ecKeyPairAlreadyExistingConvo = new ECKeyPair( const ecKeyPairAlreadyExistingConvo = new ECKeyPair(
encryptionKeyPair!.publicKey, encryptionKeyPair!.publicKey,
encryptionKeyPair!.privateKey encryptionKeyPair!.privateKey

@ -657,8 +657,8 @@ async function handleLegacyGroupUpdate(latestEnvelopeTimestamp: number) {
changes = true; changes = true;
} }
// start polling for this group if we haven't left it yet. The wrapper does not store this info for legacy group so we check from the DB entry instead // start polling for this group if we are still part of it.
if (!legacyGroupConvo.isKickedFromGroup() && !legacyGroupConvo.isLeft()) { if (!legacyGroupConvo.isKickedFromGroup()) {
getSwarmPollingInstance().addGroupId(PubKey.cast(fromWrapper.pubkeyHex)); getSwarmPollingInstance().addGroupId(PubKey.cast(fromWrapper.pubkeyHex));
// save the encryption keypair if needed // save the encryption keypair if needed

@ -365,7 +365,6 @@ async function handleGroupDeleteMemberContentMessage({
} }
// TODO we should process this message type even if the sender is blocked // TODO we should process this message type even if the sender is blocked
console.warn('Not implemented');
convo.set({ convo.set({
active_at: envelopeTimestamp, active_at: envelopeTimestamp,
}); });
@ -395,7 +394,6 @@ async function handleGroupUpdateDeleteMessage({
convo.set({ convo.set({
active_at: envelopeTimestamp, active_at: envelopeTimestamp,
}); });
console.warn('Not implemented');
throw new Error('Not implemented'); throw new Error('Not implemented');
// TODO We should process this message type even if the sender is blocked // TODO We should process this message type even if the sender is blocked
} }

@ -599,9 +599,8 @@ export class SwarmPolling {
(c.isClosedGroupV2() && (c.isClosedGroupV2() &&
!c.isBlocked() && !c.isBlocked() &&
!c.isKickedFromGroup() && !c.isKickedFromGroup() &&
!c.isLeft() &&
c.isApproved()) || c.isApproved()) ||
(c.isClosedGroup() && !c.isBlocked() && !c.isKickedFromGroup() && !c.isLeft()) (c.isClosedGroup() && !c.isBlocked() && !c.isKickedFromGroup() )
); );
closedGroupsOnly.forEach(c => { closedGroupsOnly.forEach(c => {

@ -1,7 +1,6 @@
import _ from 'lodash'; import _ from 'lodash';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { PubkeyType } from 'libsession_util_nodejs';
import { getMessageQueue } from '..'; import { getMessageQueue } from '..';
import { Data } from '../../data/data'; import { Data } from '../../data/data';
import { ConversationModel } from '../../models/conversation'; import { ConversationModel } from '../../models/conversation';

@ -1,5 +1,6 @@
import { AbortController } from 'abort-controller'; import { AbortController } from 'abort-controller';
import { PubkeyType } from 'libsession_util_nodejs';
import { MessageSender } from '.'; import { MessageSender } from '.';
import { ClosedGroupMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupMessage'; import { ClosedGroupMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupMessage';
import { ClosedGroupNameChangeMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupNameChangeMessage'; import { ClosedGroupNameChangeMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupNameChangeMessage';
@ -20,7 +21,6 @@ import {
import { SyncMessageType } from '../utils/sync/syncUtils'; import { SyncMessageType } from '../utils/sync/syncUtils';
import { MessageSentHandler } from './MessageSentHandler'; import { MessageSentHandler } from './MessageSentHandler';
import { PubkeyType } from 'libsession_util_nodejs';
import { OpenGroupRequestCommonType } from '../apis/open_group_api/opengroupV2/ApiUtil'; import { OpenGroupRequestCommonType } from '../apis/open_group_api/opengroupV2/ApiUtil';
import { OpenGroupMessageV2 } from '../apis/open_group_api/opengroupV2/OpenGroupMessageV2'; import { OpenGroupMessageV2 } from '../apis/open_group_api/opengroupV2/OpenGroupMessageV2';
import { sendSogsReactionOnionV4 } from '../apis/open_group_api/sogsv3/sogsV3SendReaction'; import { sendSogsReactionOnionV4 } from '../apis/open_group_api/sogsv3/sogsV3SendReaction';

@ -34,8 +34,7 @@ function isLegacyGroupToStoreInWrapper(convo: ConversationModel): boolean {
!convo.isPublic() && !convo.isPublic() &&
convo.id.startsWith('05') && // new closed groups won't start with 05 convo.id.startsWith('05') && // new closed groups won't start with 05
convo.isActive() && convo.isActive() &&
!convo.isKickedFromGroup() && !convo.isKickedFromGroup()
!convo.isLeft()
); );
} }

@ -264,7 +264,6 @@ export interface ReduxConversationType {
isTyping?: boolean; isTyping?: boolean;
isBlocked?: boolean; isBlocked?: boolean;
isKickedFromGroup?: boolean; isKickedFromGroup?: boolean;
left?: boolean;
avatarPath?: string | null; // absolute filepath to the avatar avatarPath?: string | null; // absolute filepath to the avatar
groupAdmins?: Array<string>; // admins for closed groups and admins for open groups groupAdmins?: Array<string>; // admins for closed groups and admins for open groups
members?: Array<string>; // members for closed groups only members?: Array<string>; // members for closed groups only

@ -90,7 +90,6 @@ export function getSelectedCanWrite(state: StateType) {
return !( return !(
isBlocked || isBlocked ||
isKickedFromGroup || isKickedFromGroup ||
left ||
readOnlySogs || readOnlySogs ||
isBlindedAndDisabledMsgRequests isBlindedAndDisabledMsgRequests
); );
@ -352,10 +351,6 @@ export function useSelectedConversationDisappearingMode():
return useSelector((state: StateType) => getSelectedConversation(state)?.expirationMode); return useSelector((state: StateType) => getSelectedConversation(state)?.expirationMode);
} }
export function useSelectedIsLeft() {
return useSelector((state: StateType) => Boolean(getSelectedConversation(state)?.left) || false);
}
export function useSelectedConversationIdOrigin() { export function useSelectedConversationIdOrigin() {
return useSelector((state: StateType) => getSelectedConversation(state)?.conversationIdOrigin); return useSelector((state: StateType) => getSelectedConversation(state)?.conversationIdOrigin);
} }

@ -26,7 +26,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
isPublic: false, isPublic: false,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -50,7 +49,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
isPublic: false, isPublic: false,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -73,7 +71,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
isPublic: false, isPublic: false,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -96,7 +93,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
isPublic: false, isPublic: false,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -119,13 +115,11 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
isPublic: false, isPublic: false,
expireTimer: 0, expireTimer: 0,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
isPrivate: false, isPrivate: false,
avatarPath: '', avatarPath: '',
groupAdmins: [], groupAdmins: [],
lastMessage: undefined, lastMessage: undefined,
@ -159,7 +153,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
expireTimer: 0, expireTimer: 0,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -184,7 +177,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
expireTimer: 0, expireTimer: 0,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -209,7 +201,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
expireTimer: 0, expireTimer: 0,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -234,7 +225,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
expireTimer: 0, expireTimer: 0,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',
weAreAdmin: false, weAreAdmin: false,
@ -258,7 +248,6 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
left: false,
expireTimer: 0, expireTimer: 0,
currentNotificationSetting: 'all', currentNotificationSetting: 'all',

Loading…
Cancel
Save