remove updateTextInputState not needed and add left to menu tests

pull/1424/head
Audric Ackermann 4 years ago
parent b15984aa08
commit 6856c0e748
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1333,9 +1333,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Ihr Gerät wurde erfolgreich getrennt." "message": "Ihr Gerät wurde erfolgreich getrennt."
}, },
"sendMessageLeftGroup": {
"message": "Du hast die Gruppe verlassen"
},
"moreInformation": { "moreInformation": {
"message": "Mehr Informationen" "message": "Mehr Informationen"
}, },

@ -959,10 +959,6 @@
"message": "Message", "message": "Message",
"description": "Placeholder text in the message entry field" "description": "Placeholder text in the message entry field"
}, },
"sendMessageLeftGroup": {
"message": "You have left the group.",
"androidKey": "MessageRecord_left_group"
},
"sendMessageBlockedUser": { "sendMessageBlockedUser": {
"message": "You have blocked this contact" "message": "You have blocked this contact"
}, },

@ -1207,9 +1207,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Tu dispositivo se ha desvinculado correctamente" "message": "Tu dispositivo se ha desvinculado correctamente"
}, },
"sendMessageLeftGroup": {
"message": "Has abandonado el grupo."
},
"moreInformation": { "moreInformation": {
"message": "Más detalles" "message": "Más detalles"
}, },

@ -1207,9 +1207,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Votre appareil a été déconnecté avec succès" "message": "Votre appareil a été déconnecté avec succès"
}, },
"sendMessageLeftGroup": {
"message": "Vous avez quitté le groupe"
},
"moreInformation": { "moreInformation": {
"message": "Plus dinformations" "message": "Plus dinformations"
}, },
@ -1768,7 +1765,6 @@
"enterOptionalPassword": { "enterOptionalPassword": {
"message": "Entrer un mot de passe (optionel)" "message": "Entrer un mot de passe (optionel)"
}, },
"devicePairingHeaderReassure": { "devicePairingHeaderReassure": {
"message": "Linking may take up to one minute to register on your primary device. Please be patient." "message": "Linking may take up to one minute to register on your primary device. Please be patient."
}, },
@ -1820,4 +1816,4 @@
"description": { "description": {
"message": "Description" "message": "Description"
} }
} }

@ -1204,9 +1204,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Sukses memutus perangkat" "message": "Sukses memutus perangkat"
}, },
"sendMessageLeftGroup": {
"message": "Anda telah keluar dari grup."
},
"moreInformation": { "moreInformation": {
"message": "Informasi lebih lanjut" "message": "Informasi lebih lanjut"
}, },

@ -1207,9 +1207,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Il dispositivo è stato scollegato correttamente" "message": "Il dispositivo è stato scollegato correttamente"
}, },
"sendMessageLeftGroup": {
"message": "Hai lasciato il gruppo."
},
"moreInformation": { "moreInformation": {
"message": "Maggiori informazioni" "message": "Maggiori informazioni"
}, },

@ -1207,9 +1207,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "デバイスは正常にリンク解除されました" "message": "デバイスは正常にリンク解除されました"
}, },
"sendMessageLeftGroup": {
"message": "グループを抜けました"
},
"moreInformation": { "moreInformation": {
"message": "詳細" "message": "詳細"
}, },

@ -1207,9 +1207,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Twoje urządzenie zostało rozłączone pomyślnie" "message": "Twoje urządzenie zostało rozłączone pomyślnie"
}, },
"sendMessageLeftGroup": {
"message": "Opuściłeś(aś) grupę."
},
"moreInformation": { "moreInformation": {
"message": "Więcej informacji" "message": "Więcej informacji"
}, },

@ -1207,9 +1207,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "O seu dispositivo foi dessincronizado com sucesso" "message": "O seu dispositivo foi dessincronizado com sucesso"
}, },
"sendMessageLeftGroup": {
"message": "Você saiu do grupo."
},
"moreInformation": { "moreInformation": {
"message": "Mais informações" "message": "Mais informações"
}, },

@ -1207,9 +1207,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Ваше устройство успешно отвязано" "message": "Ваше устройство успешно отвязано"
}, },
"sendMessageLeftGroup": {
"message": "Вы покинули группу."
},
"moreInformation": { "moreInformation": {
"message": "Больше информации" "message": "Больше информации"
}, },

@ -1192,9 +1192,6 @@
"deviceUnpaired": { "deviceUnpaired": {
"message": "Thiết bị của bạn đã được hủy liên kết thành công" "message": "Thiết bị của bạn đã được hủy liên kết thành công"
}, },
"sendMessageLeftGroup": {
"message": "Bạn đã rời nhóm."
},
"resend": { "resend": {
"message": "Gửi lại" "message": "Gửi lại"
}, },

@ -51,7 +51,6 @@ export interface ConversationModel
getRecipients: () => Array<string>; getRecipients: () => Array<string>;
getTitle: () => string; getTitle: () => string;
onReadMessage: (message: MessageModel) => void; onReadMessage: (message: MessageModel) => void;
updateTextInputState: () => void;
getName: () => string; getName: () => string;
addMessage: (attributes: Partial<MessageAttributes>) => Promise<MessageModel>; addMessage: (attributes: Partial<MessageAttributes>) => Promise<MessageModel>;
isMediumGroup: () => boolean; isMediumGroup: () => boolean;

@ -57,6 +57,7 @@
groupAdmins: [], groupAdmins: [],
isKickedFromGroup: false, isKickedFromGroup: false,
profileSharing: false, profileSharing: false,
left: false,
}; };
}, },
@ -214,9 +215,7 @@
? BlockedNumberController.block(this.id) ? BlockedNumberController.block(this.id)
: BlockedNumberController.blockGroup(this.id); : BlockedNumberController.blockGroup(this.id);
await promise; await promise;
this.trigger('change', this); this.commit();
this.messageCollection.forEach(m => m.trigger('change'));
this.updateTextInputState();
await textsecure.messaging.sendBlockedListSyncMessage(); await textsecure.messaging.sendBlockedListSyncMessage();
}, },
async unblock() { async unblock() {
@ -227,14 +226,11 @@
? BlockedNumberController.unblock(this.id) ? BlockedNumberController.unblock(this.id)
: BlockedNumberController.unblockGroup(this.id); : BlockedNumberController.unblockGroup(this.id);
await promise; await promise;
this.trigger('change', this); this.commit();
this.messageCollection.forEach(m => m.trigger('change'));
this.updateTextInputState();
await textsecure.messaging.sendBlockedListSyncMessage(); await textsecure.messaging.sendBlockedListSyncMessage();
}, },
async bumpTyping() { async bumpTyping() {
if (this.isPublic()) { if (this.isPublic() || this.isMediumGroup()) {
window.log.debug('public conversation... No need to bumpTyping');
return; return;
} }
// We don't send typing messages if the setting is disabled or we do not have a session // We don't send typing messages if the setting is disabled or we do not have a session
@ -308,49 +304,37 @@
}, },
sendTypingMessage(isTyping) { sendTypingMessage(isTyping) {
// Loki - Temporarily disable typing messages for groups
if (!this.isPrivate()) { if (!this.isPrivate()) {
return; return;
} }
const groupId = !this.isPrivate() ? this.id : null; const recipientId = this.id;
const recipientId = this.isPrivate() ? this.id : null;
if (!recipientId) {
throw new Error('Need to provide either recipientId');
}
// We don't want to send typing messages to our other devices, but we will
// in the group case.
const primaryDevicePubkey = window.storage.get('primaryDevicePubKey'); const primaryDevicePubkey = window.storage.get('primaryDevicePubKey');
if (recipientId && primaryDevicePubkey === recipientId) { if (recipientId && primaryDevicePubkey === recipientId) {
// note to self
return; return;
} }
if (!recipientId && !groupId) {
throw new Error('Need to provide either recipientId or groupId!');
}
const typingParams = { const typingParams = {
timestamp: Date.now(), timestamp: Date.now(),
isTyping, isTyping,
typingTimestamp: Date.now(), typingTimestamp: Date.now(),
groupId, // might be null
}; };
const typingMessage = new libsession.Messages.Outgoing.TypingMessage( const typingMessage = new libsession.Messages.Outgoing.TypingMessage(
typingParams typingParams
); );
// send the message to a single recipient if this is a session chat // send the message to a single recipient if this is a session chat
if (this.isPrivate()) { const device = new libsession.Types.PubKey(recipientId);
const device = new libsession.Types.PubKey(recipientId); libsession
libsession .getMessageQueue()
.getMessageQueue() .sendUsingMultiDevice(device, typingMessage)
.sendUsingMultiDevice(device, typingMessage) .catch(log.error);
.catch(log.error);
} else {
// the recipients on the case of a group are found by the messageQueue using message.groupId
libsession
.getMessageQueue()
.sendToGroup(typingMessage)
.catch(log.error);
}
}, },
async cleanup() { async cleanup() {
@ -460,7 +444,7 @@
messageModel: model, messageModel: model,
}); });
this.trigger('change', this); this.commit();
}, },
addSingleMessage(message, setToExpire = true) { addSingleMessage(message, setToExpire = true) {
const model = this.messageCollection.add(message, { merge: true }); const model = this.messageCollection.add(message, { merge: true });
@ -508,7 +492,7 @@
}, },
hasNickname: !!this.getNickname(), hasNickname: !!this.getNickname(),
isKickedFromGroup: !!this.get('isKickedFromGroup'), isKickedFromGroup: !!this.get('isKickedFromGroup'),
leftGroup: !!this.get('left'), left: !!this.get('left'),
onClick: () => this.trigger('select', this), onClick: () => this.trigger('select', this),
onBlockContact: () => this.block(), onBlockContact: () => this.block(),
@ -560,8 +544,6 @@
} }
}) })
); );
this.onMemberVerifiedChange();
}, },
setVerifiedDefault(options) { setVerifiedDefault(options) {
const { DEFAULT } = this.verifiedEnum; const { DEFAULT } = this.verifiedEnum;
@ -672,36 +654,6 @@
// Something funky has happened // Something funky has happened
return this; return this;
}, },
async updateTextInputState() {
if (this.isRss()) {
// or if we're an rss conversation, disable it
this.trigger('disable:input', true);
return;
}
if (this.isSecondaryDevice()) {
// Or if we're a secondary device, update the primary device text input
const primaryConversation = await this.getPrimaryConversation();
primaryConversation.updateTextInputState();
return;
}
if (this.get('isKickedFromGroup')) {
this.trigger('disable:input', true);
return;
}
if (!this.isPrivate() && this.get('left')) {
this.trigger('disable:input', true);
this.trigger('change:placeholder', 'left-group');
return;
}
if (this.isBlocked()) {
this.trigger('disable:input', true);
this.trigger('change:placeholder', 'blocked-user');
return;
}
// otherwise, enable the input and set default placeholder
this.trigger('disable:input', false);
this.trigger('change:placeholder', 'chat');
},
isSecondaryDevice() { isSecondaryDevice() {
return !!this.get('secondaryStatus'); return !!this.get('secondaryStatus');
}, },
@ -819,12 +771,6 @@
); );
}); });
}, },
onMemberVerifiedChange() {
// If the verified state of a member changes, our aggregate state changes.
// We trigger both events to replicate the behavior of Backbone.Model.set()
this.trigger('change:verified', this);
this.trigger('change', this);
},
toggleVerified() { toggleVerified() {
if (this.isVerified()) { if (this.isVerified()) {
return this.setVerifiedDefault(); return this.setVerifiedDefault();
@ -1650,8 +1596,6 @@
'Legacy group are not supported anymore. You need to create this group again.' 'Legacy group are not supported anymore. You need to create this group again.'
); );
} }
this.updateTextInputState();
}, },
async markRead(newestUnreadDate, providedOptions) { async markRead(newestUnreadDate, providedOptions) {
@ -2039,14 +1983,6 @@
); );
return Promise.all(promises).then(contacts => { return Promise.all(promises).then(contacts => {
_.forEach(contacts, contact => {
this.listenTo(
contact,
'change:verified',
this.onMemberVerifiedChange
);
});
this.contactCollection.reset(contacts); this.contactCollection.reset(contacts);
}); });
}, },
@ -2401,14 +2337,14 @@
if (!record) { if (!record) {
// User was not previously typing before. State change! // User was not previously typing before. State change!
this.trigger('typing-update'); this.trigger('typing-update');
this.trigger('change', this); this.commit();
} }
} else { } else {
delete this.contactTypingTimers[identifier]; delete this.contactTypingTimers[identifier];
if (record) { if (record) {
// User was previously typing, and is no longer. State change! // User was previously typing, and is no longer. State change!
this.trigger('typing-update'); this.trigger('typing-update');
this.trigger('change', this); this.commit();
} }
} }
}, },
@ -2423,7 +2359,7 @@
// User was previously typing, but timed out or we received message. State change! // User was previously typing, but timed out or we received message. State change!
this.trigger('typing-update'); this.trigger('typing-update');
this.trigger('change', this); this.commit();
} }
}, },
}); });

@ -235,9 +235,9 @@ async function _finishJob(message, id) {
if (fromConversation && message !== fromConversation) { if (fromConversation && message !== fromConversation) {
fromConversation.set(message.attributes); fromConversation.set(message.attributes);
fromConversation.trigger('change', fromConversation); fromConversation.commit();
} else { } else {
message.trigger('change', message); message.commit();
} }
} }
} }

@ -207,8 +207,7 @@
window.confirmationDialog({ window.confirmationDialog({
title, title,
message, message,
resolve: () => resolve: () => groupConvo.leaveGroup(),
window.getConversationController().deleteContact(groupConvo.id),
theme: this.getThemeObject(), theme: this.getThemeObject(),
}); });
} else { } else {

@ -37,12 +37,9 @@
}, },
initialize(options) { initialize(options) {
this.listenTo(this.model, 'destroy', this.stopListening); this.listenTo(this.model, 'destroy', this.stopListening);
this.listenTo(this.model, 'change:verified', this.onVerifiedChange);
this.listenTo(this.model, 'newmessage', this.addMessage); this.listenTo(this.model, 'newmessage', this.addMessage);
this.listenTo(this.model, 'opened', this.onOpened); this.listenTo(this.model, 'opened', this.onOpened);
this.listenTo(this.model, 'prune', this.onPrune); this.listenTo(this.model, 'prune', this.onPrune);
this.listenTo(this.model, 'disable:input', this.onDisableInput);
this.listenTo(this.model, 'change:placeholder', this.onChangePlaceholder);
this.listenTo(this.model, 'unload', () => this.unload('model trigger')); this.listenTo(this.model, 'unload', () => this.unload('model trigger'));
this.listenTo(this.model, 'typing-update', this.renderTypingBubble); this.listenTo(this.model, 'typing-update', this.renderTypingBubble);
this.listenTo( this.listenTo(
@ -98,8 +95,6 @@
this.render(); this.render();
this.model.updateTextInputState();
this.window = options.window; this.window = options.window;
Whisper.events.on('mediaPermissionsChanged', () => Whisper.events.on('mediaPermissionsChanged', () =>
@ -127,8 +122,6 @@
this.$('.send-message').focus(this.focusBottomBar.bind(this)); this.$('.send-message').focus(this.focusBottomBar.bind(this));
this.$('.send-message').blur(this.unfocusBottomBar.bind(this)); this.$('.send-message').blur(this.unfocusBottomBar.bind(this));
this.model.updateTextInputState();
this.selectMember = this.selectMember.bind(this); this.selectMember = this.selectMember.bind(this);
const updateMemberList = async () => { const updateMemberList = async () => {

@ -54,6 +54,7 @@ export type ConversationListItemProps = {
isSecondary?: boolean; isSecondary?: boolean;
isGroupInvitation?: boolean; isGroupInvitation?: boolean;
isKickedFromGroup?: boolean; isKickedFromGroup?: boolean;
left?: boolean;
memberAvatars?: Array<ConversationAvatar>; // this is added by usingClosedConversationDetails memberAvatars?: Array<ConversationAvatar>; // this is added by usingClosedConversationDetails
}; };

@ -62,6 +62,7 @@ interface Props {
isBlocked: boolean; isBlocked: boolean;
isKickedFromGroup: boolean; isKickedFromGroup: boolean;
left: boolean;
selectionMode: boolean; // is the UI on the message selection mode or not selectionMode: boolean; // is the UI on the message selection mode or not
onInviteContacts: () => void; onInviteContacts: () => void;

@ -63,7 +63,7 @@ interface Props {
isBlocked: boolean; isBlocked: boolean;
isPrivate: boolean; isPrivate: boolean;
isKickedFromGroup: boolean; isKickedFromGroup: boolean;
leftGroup: boolean; left: boolean;
conversationKey: string; conversationKey: string;
isPublic: boolean; isPublic: boolean;
@ -259,9 +259,9 @@ export class SessionCompositionBox extends React.Component<Props, State> {
} }
private isTypingEnabled(): boolean { private isTypingEnabled(): boolean {
const { isBlocked, isKickedFromGroup, leftGroup, isPrivate } = this.props; const { isBlocked, isKickedFromGroup, left, isPrivate } = this.props;
return !(isBlocked || isKickedFromGroup || leftGroup); return !(isBlocked || isKickedFromGroup || left);
} }
private renderCompositionView() { private renderCompositionView() {
@ -347,10 +347,10 @@ export class SessionCompositionBox extends React.Component<Props, State> {
private renderTextArea() { private renderTextArea() {
const { i18n } = window; const { i18n } = window;
const { message } = this.state; const { message } = this.state;
const { isKickedFromGroup, leftGroup, isPrivate, isBlocked } = this.props; const { isKickedFromGroup, left, isPrivate, isBlocked } = this.props;
const messagePlaceHolder = isKickedFromGroup const messagePlaceHolder = isKickedFromGroup
? i18n('youGotKickedFromGroup') ? i18n('youGotKickedFromGroup')
: leftGroup : left
? i18n('youLeftTheGroup') ? i18n('youLeftTheGroup')
: isBlocked && isPrivate : isBlocked && isPrivate
? i18n('unblockToSend') ? i18n('unblockToSend')
@ -784,7 +784,7 @@ export class SessionCompositionBox extends React.Component<Props, State> {
this.parseEmojis(this.state.message) this.parseEmojis(this.state.message)
); );
const { isBlocked, isPrivate, leftGroup, isKickedFromGroup } = this.props; const { isBlocked, isPrivate, left, isKickedFromGroup } = this.props;
// deny sending of message if our app version is expired // deny sending of message if our app version is expired
if (window.extension.expiredStatus() === true) { if (window.extension.expiredStatus() === true) {
@ -827,7 +827,7 @@ export class SessionCompositionBox extends React.Component<Props, State> {
} }
} }
if (!isPrivate && leftGroup) { if (!isPrivate && left) {
ToastUtils.pushYouLeftTheGroup(); ToastUtils.pushYouLeftTheGroup();
return; return;
} }

@ -346,7 +346,7 @@ export class SessionConversation extends React.Component<Props, State> {
// tslint:disable-next-line: use-simple-attributes // tslint:disable-next-line: use-simple-attributes
<SessionCompositionBox <SessionCompositionBox
isBlocked={conversation.isBlocked} isBlocked={conversation.isBlocked}
leftGroup={conversation.leftGroup} left={conversation.left}
isKickedFromGroup={conversation.isKickedFromGroup} isKickedFromGroup={conversation.isKickedFromGroup}
isPrivate={conversation.type === 'direct'} isPrivate={conversation.type === 'direct'}
isPublic={conversation.isPublic || false} isPublic={conversation.isPublic || false}
@ -450,6 +450,7 @@ export class SessionConversation extends React.Component<Props, State> {
members, members,
subscriberCount: conversation.get('subscriberCount'), subscriberCount: conversation.get('subscriberCount'),
isKickedFromGroup: conversation.get('isKickedFromGroup'), isKickedFromGroup: conversation.get('isKickedFromGroup'),
left: conversation.get('left'),
expirationSettingName, expirationSettingName,
showBackButton: Boolean(infoViewState || messageDetailShowProps), showBackButton: Boolean(infoViewState || messageDetailShowProps),
timerOptions: window.Whisper.ExpirationTimerOptions.map((item: any) => ({ timerOptions: window.Whisper.ExpirationTimerOptions.map((item: any) => ({
@ -561,10 +562,10 @@ export class SessionConversation extends React.Component<Props, State> {
memberCount: members.length, memberCount: members.length,
phoneNumber: conversation.getNumber(), phoneNumber: conversation.getNumber(),
profileName: conversation.getProfileName(), profileName: conversation.getProfileName(),
description: '', // TODO VINCE: ENSURE DESCRIPTION IS SET
avatarPath: conversation.getAvatarPath(), avatarPath: conversation.getAvatarPath(),
amMod: conversation.isModerator(), amMod: conversation.isModerator(),
isKickedFromGroup: conversation.attributes.isKickedFromGroup, isKickedFromGroup: conversation.get('isKickedFromGroup'),
left: conversation.get('left'),
isGroup: !conversation.isPrivate(), isGroup: !conversation.isPrivate(),
isPublic: conversation.isPublic(), isPublic: conversation.isPublic(),
isAdmin, isAdmin,

@ -31,6 +31,7 @@ interface Props {
isAdmin: boolean; isAdmin: boolean;
amMod: boolean; amMod: boolean;
isKickedFromGroup: boolean; isKickedFromGroup: boolean;
left: boolean;
isBlocked: boolean; isBlocked: boolean;
isGroup: boolean; isGroup: boolean;
memberAvatars?: Array<ConversationAvatar>; // this is added by usingClosedConversationDetails memberAvatars?: Array<ConversationAvatar>; // this is added by usingClosedConversationDetails
@ -235,6 +236,7 @@ class SessionRightPanel extends React.Component<Props, State> {
this.props.onShowLightBox(options); this.props.onShowLightBox(options);
} }
// tslint:disable-next-line: cyclomatic-complexity
public render() { public render() {
const { const {
memberCount, memberCount,
@ -242,6 +244,7 @@ class SessionRightPanel extends React.Component<Props, State> {
timerOptions, timerOptions,
onLeaveGroup, onLeaveGroup,
isKickedFromGroup, isKickedFromGroup,
left,
isPublic, isPublic,
isAdmin, isAdmin,
amMod, amMod,
@ -250,12 +253,15 @@ class SessionRightPanel extends React.Component<Props, State> {
} = this.props; } = this.props;
const { documents, media, onItemClick } = this.state; const { documents, media, onItemClick } = this.state;
const showMemberCount = !!(memberCount && memberCount > 0); const showMemberCount = !!(memberCount && memberCount > 0);
const hasDisappearingMessages = const commonNoShow = isKickedFromGroup || left || isBlocked;
!isPublic && !isKickedFromGroup && !isBlocked;
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('youLeftTheGroup')
: window.i18n('leaveGroup'); : window.i18n('leaveGroup');
const disappearingMessagesOptions = timerOptions.map(option => { const disappearingMessagesOptions = timerOptions.map(option => {
@ -268,11 +274,10 @@ class SessionRightPanel extends React.Component<Props, State> {
}); });
const showUpdateGroupNameButton = const showUpdateGroupNameButton =
isPublic && !isKickedFromGroup isPublic && !commonNoShow
? amMod && !isBlocked ? amMod && !commonNoShow
: isAdmin && !isBlocked && !isKickedFromGroup; : isAdmin && !commonNoShow;
const showUpdateGroupMembersButton = const showUpdateGroupMembersButton = !isPublic && !commonNoShow && isAdmin;
!isPublic && !isKickedFromGroup && !isBlocked && isAdmin;
return ( return (
<div className="group-settings"> <div className="group-settings">
@ -326,7 +331,7 @@ class SessionRightPanel extends React.Component<Props, State> {
<SessionButton <SessionButton
text={leaveGroupString} text={leaveGroupString}
buttonColor={SessionButtonColor.Danger} buttonColor={SessionButtonColor.Danger}
disabled={isKickedFromGroup} disabled={isKickedFromGroup || left}
buttonType={SessionButtonType.SquareOutline} buttonType={SessionButtonType.SquareOutline}
onClick={onLeaveGroup} onClick={onLeaveGroup}
/> />
@ -349,10 +354,11 @@ class SessionRightPanel extends React.Component<Props, State> {
name, name,
profileName, profileName,
phoneNumber, phoneNumber,
left,
} = this.props; } = this.props;
const showInviteContacts = const showInviteContacts =
(isPublic || isAdmin) && !isKickedFromGroup && !isBlocked; (isPublic || isAdmin) && !isKickedFromGroup && !isBlocked && !left;
const userName = name || profileName || phoneNumber; const userName = name || profileName || phoneNumber;
return ( return (

@ -23,6 +23,7 @@ export type PropsConversationHeaderMenu = {
isRss?: boolean; isRss?: boolean;
isClosable?: boolean; isClosable?: boolean;
isKickedFromGroup?: boolean; isKickedFromGroup?: boolean;
left?: boolean;
isGroup: boolean; isGroup: boolean;
amMod: boolean; amMod: boolean;
timerOptions: Array<TimerOption>; timerOptions: Array<TimerOption>;
@ -57,6 +58,7 @@ export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => {
timerOptions, timerOptions,
isBlocked, isBlocked,
isPrivate, isPrivate,
left,
onDeleteMessages, onDeleteMessages,
onDeleteContact, onDeleteContact,
@ -79,6 +81,7 @@ export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => {
isPublic, isPublic,
isRss, isRss,
isKickedFromGroup, isKickedFromGroup,
left,
isBlocked, isBlocked,
timerOptions, timerOptions,
onSetDisappearingMessages, onSetDisappearingMessages,
@ -126,11 +129,13 @@ export const ConversationHeaderMenu = (props: PropsConversationHeaderMenu) => {
{getUpdateGroupNameMenuItem( {getUpdateGroupNameMenuItem(
amMod, amMod,
isKickedFromGroup, isKickedFromGroup,
left,
onUpdateGroupName, onUpdateGroupName,
window.i18n window.i18n
)} )}
{getLeaveGroupMenuItem( {getLeaveGroupMenuItem(
isKickedFromGroup, isKickedFromGroup,
left,
isGroup, isGroup,
isPublic, isPublic,
isRss, isRss,

@ -21,6 +21,7 @@ export type PropsContextConversationItem = {
isBlocked?: boolean; isBlocked?: boolean;
hasNickname?: boolean; hasNickname?: boolean;
isKickedFromGroup?: boolean; isKickedFromGroup?: boolean;
left?: boolean;
onDeleteMessages?: () => void; onDeleteMessages?: () => void;
onDeleteContact?: () => void; onDeleteContact?: () => void;
@ -44,6 +45,7 @@ export const ConversationListItemContextMenu = (
isPublic, isPublic,
hasNickname, hasNickname,
type, type,
left,
isKickedFromGroup, isKickedFromGroup,
onDeleteContact, onDeleteContact,
onDeleteMessages, onDeleteMessages,
@ -103,6 +105,7 @@ export const ConversationListItemContextMenu = (
)} )}
{getLeaveGroupMenuItem( {getLeaveGroupMenuItem(
isKickedFromGroup, isKickedFromGroup,
left,
type === 'group', type === 'group',
isPublic, isPublic,
isRss, isRss,

@ -7,9 +7,10 @@ function showTimerOptions(
isPublic: boolean, isPublic: boolean,
isRss: boolean, isRss: boolean,
isKickedFromGroup: boolean, isKickedFromGroup: boolean,
left: boolean,
isBlocked: boolean isBlocked: boolean
): boolean { ): boolean {
return !isPublic && !isRss && !isKickedFromGroup && !isBlocked; return !isPublic && !isRss && !left && !isKickedFromGroup && !isBlocked;
} }
function showMemberMenu( function showMemberMenu(
@ -89,18 +90,20 @@ function showRemoveModerators(
function showUpdateGroupName( function showUpdateGroupName(
amMod: boolean, amMod: boolean,
isKickedFromGroup: boolean isKickedFromGroup: boolean,
left: boolean
): boolean { ): boolean {
return !isKickedFromGroup && amMod; return !isKickedFromGroup && !left && amMod;
} }
function showLeaveGroup( function showLeaveGroup(
isKickedFromGroup: boolean, isKickedFromGroup: boolean,
left: boolean,
isGroup: boolean, isGroup: boolean,
isPublic: boolean, isPublic: boolean,
isRss: boolean isRss: boolean
): boolean { ): boolean {
return !isKickedFromGroup && isGroup && !isPublic && !isRss; return !isKickedFromGroup && !left && isGroup && !isPublic && !isRss;
} }
function showInviteContact(isGroup: boolean, isPublic: boolean): boolean { function showInviteContact(isGroup: boolean, isPublic: boolean): boolean {
@ -149,6 +152,7 @@ export function getDeleteContactMenuItem(
export function getLeaveGroupMenuItem( export function getLeaveGroupMenuItem(
isKickedFromGroup: boolean | undefined, isKickedFromGroup: boolean | undefined,
left: boolean | undefined,
isGroup: boolean | undefined, isGroup: boolean | undefined,
isPublic: boolean | undefined, isPublic: boolean | undefined,
isRss: boolean | undefined, isRss: boolean | undefined,
@ -158,6 +162,7 @@ export function getLeaveGroupMenuItem(
if ( if (
showLeaveGroup( showLeaveGroup(
Boolean(isKickedFromGroup), Boolean(isKickedFromGroup),
Boolean(left),
Boolean(isGroup), Boolean(isGroup),
Boolean(isPublic), Boolean(isPublic),
Boolean(isRss) Boolean(isRss)
@ -171,10 +176,17 @@ export function getLeaveGroupMenuItem(
export function getUpdateGroupNameMenuItem( export function getUpdateGroupNameMenuItem(
amMod: boolean | undefined, amMod: boolean | undefined,
isKickedFromGroup: boolean | undefined, isKickedFromGroup: boolean | undefined,
left: boolean | undefined,
action: any, action: any,
i18n: LocalizerType i18n: LocalizerType
): JSX.Element | null { ): JSX.Element | null {
if (showUpdateGroupName(Boolean(amMod), Boolean(isKickedFromGroup))) { if (
showUpdateGroupName(
Boolean(amMod),
Boolean(isKickedFromGroup),
Boolean(left)
)
) {
return <Item onClick={action}>{i18n('editGroup')}</Item>; return <Item onClick={action}>{i18n('editGroup')}</Item>;
} }
return null; return null;
@ -222,6 +234,7 @@ export function getDisappearingMenuItem(
isPublic: boolean | undefined, isPublic: boolean | undefined,
isRss: boolean | undefined, isRss: boolean | undefined,
isKickedFromGroup: boolean | undefined, isKickedFromGroup: boolean | undefined,
left: boolean | undefined,
isBlocked: boolean | undefined, isBlocked: boolean | undefined,
timerOptions: Array<TimerOption>, timerOptions: Array<TimerOption>,
action: any, action: any,
@ -232,6 +245,7 @@ export function getDisappearingMenuItem(
Boolean(isPublic), Boolean(isPublic),
Boolean(isRss), Boolean(isRss),
Boolean(isKickedFromGroup), Boolean(isKickedFromGroup),
Boolean(left),
Boolean(isBlocked) Boolean(isBlocked)
) )
) { ) {

@ -188,14 +188,16 @@ async function handleNewClosedGroupV2(
const groupExists = !!maybeConvo; const groupExists = !!maybeConvo;
if (groupExists) { if (groupExists) {
if (maybeConvo && maybeConvo.get('isKickedFromGroup')) { if (
maybeConvo &&
(maybeConvo.get('isKickedFromGroup') || maybeConvo.get('left'))
) {
// TODO: indicate that we've been re-invited // TODO: indicate that we've been re-invited
// to the group if that is the case // to the group if that is the case
// Enable typing: // Enable typing:
maybeConvo.set('isKickedFromGroup', false); maybeConvo.set('isKickedFromGroup', false);
maybeConvo.set('left', false); maybeConvo.set('left', false);
maybeConvo.updateTextInputState();
} else { } else {
log.warn( log.warn(
'Ignoring a closed group v2 message of type NEW: the conversation already exists' 'Ignoring a closed group v2 message of type NEW: the conversation already exists'
@ -305,7 +307,6 @@ async function handleUpdateClosedGroupV2(
); );
convo.set('isKickedFromGroup', true); convo.set('isKickedFromGroup', true);
// Disable typing: // Disable typing:
convo.updateTextInputState();
window.SwarmPolling.removePubkey(groupPublicKey); window.SwarmPolling.removePubkey(groupPublicKey);
} else { } else {
if (convo.get('isKickedFromGroup')) { if (convo.get('isKickedFromGroup')) {
@ -314,7 +315,6 @@ async function handleUpdateClosedGroupV2(
convo.set('left', false); convo.set('left', false);
// Subscribe to this group id // Subscribe to this group id
window.SwarmPolling.addGroupId(new PubKey(groupPublicKey)); window.SwarmPolling.addGroupId(new PubKey(groupPublicKey));
convo.updateTextInputState();
} }
} }

@ -179,7 +179,7 @@ async function handleAuthorisationForSelf(
primaryDevicePubKey, primaryDevicePubKey,
'private' 'private'
); );
primaryConversation.trigger('change'); await primaryConversation.commit();
Whisper.events.trigger('secondaryDeviceRegistration'); Whisper.events.trigger('secondaryDeviceRegistration');
// Update profile // Update profile
if (dataMessage) { if (dataMessage) {
@ -430,7 +430,6 @@ async function onContactReceived(details: any) {
if (conversation.isPrivate()) { if (conversation.isPrivate()) {
await BlockedNumberController.setBlocked(conversation.id, isBlocked); await BlockedNumberController.setBlocked(conversation.id, isBlocked);
} }
conversation.updateTextInputState();
await conversation.commit(); await conversation.commit();
} catch (error) { } catch (error) {

@ -420,9 +420,6 @@ async function handleRegularMessage(
conversation.set({ active_at: now }); conversation.set({ active_at: now });
// Re-enable typing if re-joined the group
conversation.updateTextInputState();
// Handle expireTimer found directly as part of a regular message // Handle expireTimer found directly as part of a regular message
await handleExpireTimer( await handleExpireTimer(
source, source,

@ -33,7 +33,7 @@ export class ConversationController {
return this.conversations.get(id); return this.conversations.get(id);
} }
public getOrThrow(id: string) { public getOrThrow(id: string): ConversationModel {
if (!this._initialFetchComplete) { if (!this._initialFetchComplete) {
throw new Error( throw new Error(
'ConversationController.get() needs complete initial fetch' 'ConversationController.get() needs complete initial fetch'

@ -262,7 +262,6 @@ export async function updateOrCreateClosedGroupV2(details: GroupInfo) {
} }
await conversation.commit(); await conversation.commit();
conversation.updateTextInputState();
const { expireTimer } = details; const { expireTimer } = details;
@ -294,7 +293,7 @@ export async function leaveClosedGroupV2(groupId: string) {
// FIXME audric, add a flag to conversation model when a group is destroyed // FIXME audric, add a flag to conversation model when a group is destroyed
if (isCurrentUserAdmin) { if (isCurrentUserAdmin) {
window.log.info('Admin left a closed group v2. We need to destroy it'); window.log.info('Admin left a closed group v2. We need to destroy it');
convo.set({ left: true, isKickedFromGroup: true }); convo.set({ left: true });
members = []; members = [];
} else { } else {
convo.set({ left: true }); convo.set({ left: true });

@ -77,7 +77,7 @@ export type ConversationType = {
primaryDevice: string; primaryDevice: string;
isBlocked: boolean; isBlocked: boolean;
isKickedFromGroup: boolean; isKickedFromGroup: boolean;
leftGroup: boolean; left: boolean;
avatarPath?: string; // absolute filepath to the avatar avatarPath?: string; // absolute filepath to the avatar
}; };
export type ConversationLookupType = { export type ConversationLookupType = {

@ -31,7 +31,7 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
leftGroup: false, left: false,
}, },
id2: { id2: {
id: 'id2', id: 'id2',
@ -52,7 +52,7 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
leftGroup: false, left: false,
}, },
id3: { id3: {
id: 'id3', id: 'id3',
@ -73,7 +73,7 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
leftGroup: false, left: false,
}, },
id4: { id4: {
id: 'id4', id: 'id4',
@ -93,7 +93,7 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
leftGroup: false, left: false,
}, },
id5: { id5: {
id: 'id5', id: 'id5',
@ -114,7 +114,7 @@ describe('state/selectors/conversations', () => {
isTyping: false, isTyping: false,
isBlocked: false, isBlocked: false,
isKickedFromGroup: false, isKickedFromGroup: false,
leftGroup: false, left: false,
}, },
}; };
const comparator = _getConversationComparator(i18n, regionCode); const comparator = _getConversationComparator(i18n, regionCode);

Loading…
Cancel
Save