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;
width: 100%;
height: 0;
overflow-y: auto;
background-color: inherit;
outline: none;
position: relative;

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

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

@ -12,7 +12,6 @@ import {
useIsGroupV2,
useIsIncomingRequest,
useIsKickedFromGroup,
useIsLeft,
useIsMe,
useIsPrivate,
useIsPrivateAndFriend,
@ -138,14 +137,13 @@ export const DeleteGroupOrCommunityMenuItem = () => {
const dispatch = useDispatch();
const convoId = useConvoIdFromContext();
const isPublic = useIsPublic(convoId);
const isLeft = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId);
const isPrivate = useIsPrivate(convoId);
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.
// 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 onClickClose = () => {
@ -183,11 +181,10 @@ export const DeleteGroupOrCommunityMenuItem = () => {
export const LeaveGroupMenuItem = () => {
const convoId = useConvoIdFromContext();
const isPublic = useIsPublic(convoId);
const isLeft = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId);
const isPrivate = useIsPrivate(convoId);
if (!isKickedFromGroup && !isLeft && !isPrivate && !isPublic) {
if (!isKickedFromGroup && !isPrivate && !isPublic) {
return (
<Item
onClick={() => {
@ -233,11 +230,10 @@ export const ShowUserDetailsMenuItem = () => {
export const UpdateGroupNameMenuItem = () => {
const convoId = useConvoIdFromContext();
const left = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId);
const weAreAdmin = useWeAreAdmin(convoId);
if (!isKickedFromGroup && !left && weAreAdmin) {
if (!isKickedFromGroup && weAreAdmin) {
return (
<Item
onClick={() => {
@ -562,19 +558,11 @@ export const NotificationForConvoMenuItem = (): JSX.Element | null => {
const currentNotificationSetting = useNotificationSetting(convoId);
const isBlocked = useIsBlocked(convoId);
const isActive = useIsActive(convoId);
const isLeft = useIsLeft(convoId);
const isKickedFromGroup = useIsKickedFromGroup(convoId);
const isFriend = useIsPrivateAndFriend(convoId);
const isPrivate = useIsPrivate(convoId);
if (
!convoId ||
isLeft ||
isKickedFromGroup ||
isBlocked ||
!isActive ||
(isPrivate && !isFriend)
) {
if (!convoId || isKickedFromGroup || isBlocked || !isActive || (isPrivate && !isFriend)) {
return null;
}

@ -22,7 +22,7 @@ import {
import { useLibGroupAdmins, useLibGroupMembers, useLibGroupName } from '../state/selectors/groups';
import { isPrivateAndFriend } from '../state/selectors/selectedConversation';
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) {
const convoProps = useConversationPropsById(convoId);

@ -411,9 +411,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
if (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
const zombies = this.getGroupZombies() || [];
if (zombies?.length) {
@ -1916,24 +1913,13 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
public isKickedFromGroup(): boolean {
if (this.isClosedGroup()) {
if (this.isClosedGroupV2()) {
// console.info('isKickedFromGroup using lib todo'); // debugger
return getLibGroupKickedOutsideRedux(this.id) || false;
}
return !!this.get('isKickedFromGroup');
}
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 {
return this.get('active_at');
}

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

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

@ -657,8 +657,8 @@ async function handleLegacyGroupUpdate(latestEnvelopeTimestamp: number) {
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
if (!legacyGroupConvo.isKickedFromGroup() && !legacyGroupConvo.isLeft()) {
// start polling for this group if we are still part of it.
if (!legacyGroupConvo.isKickedFromGroup()) {
getSwarmPollingInstance().addGroupId(PubKey.cast(fromWrapper.pubkeyHex));
// 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
console.warn('Not implemented');
convo.set({
active_at: envelopeTimestamp,
});
@ -395,7 +394,6 @@ async function handleGroupUpdateDeleteMessage({
convo.set({
active_at: envelopeTimestamp,
});
console.warn('Not implemented');
throw new Error('Not implemented');
// TODO We should process this message type even if the sender is blocked
}

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

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

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

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

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

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

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

Loading…
Cancel
Save