Merge pull request #1611 from Bilb/fix-remove-member-no-convo

create convo for members if they don't exist
pull/1616/head
Audric Ackermann 4 years ago committed by GitHub
commit 2e5a27a81c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -486,7 +486,20 @@ export class SessionConversation extends React.Component<Props, State> {
onUpdateGroupName: () => { onUpdateGroupName: () => {
window.Whisper.events.trigger('updateGroupName', conversation); window.Whisper.events.trigger('updateGroupName', conversation);
}, },
onUpdateGroupMembers: () => { onUpdateGroupMembers: async () => {
if (conversation.isMediumGroup()) {
// make sure all the members' convo exists so we can add or remove them
await Promise.all(
conversation
.get('members')
.map(m =>
ConversationController.getInstance().getOrCreateAndWait(
m,
ConversationTypeEnum.PRIVATE
)
)
);
}
window.Whisper.events.trigger('updateGroupMembers', conversation); window.Whisper.events.trigger('updateGroupMembers', conversation);
}, },
onInviteContacts: () => { onInviteContacts: () => {

@ -34,6 +34,7 @@ export class ConversationController {
return ConversationController.instance; return ConversationController.instance;
} }
ConversationController.instance = new ConversationController(); ConversationController.instance = new ConversationController();
return ConversationController.instance; return ConversationController.instance;
} }
@ -187,9 +188,10 @@ export class ConversationController {
return; return;
} }
// Close group leaving // Closed/Medium group leaving
if (conversation.isClosedGroup()) { if (conversation.isClosedGroup()) {
await conversation.leaveClosedGroup(); await conversation.leaveClosedGroup();
// open group v1
} else if (conversation.isPublic() && !conversation.isOpenGroupV2()) { } else if (conversation.isPublic() && !conversation.isOpenGroupV2()) {
const channelAPI = await conversation.getPublicSendData(); const channelAPI = await conversation.getPublicSendData();
if (channelAPI === null) { if (channelAPI === null) {
@ -197,6 +199,7 @@ export class ConversationController {
} else { } else {
channelAPI.serverAPI.partChannel((channelAPI as any).channelId); channelAPI.serverAPI.partChannel((channelAPI as any).channelId);
} }
// open group v2
} else if (conversation.isOpenGroupV2()) { } else if (conversation.isOpenGroupV2()) {
window.log.info('leaving open group v2', conversation.id); window.log.info('leaving open group v2', conversation.id);
const roomInfos = await getV2OpenGroupRoom(conversation.id); const roomInfos = await getV2OpenGroupRoom(conversation.id);
@ -220,10 +223,21 @@ export class ConversationController {
// those are the stuff to do for all contact types // those are the stuff to do for all contact types
await conversation.destroyMessages(); await conversation.destroyMessages();
await removeConversation(id); // if this conversation is a private conversation it's in fact a `contact` for desktop.
this.conversations.remove(conversation); // we just want to remove everything related to it, set the active_at to undefined
if (window.inboxStore) { // so conversation still exists (useful for medium groups members or opengroups) but is not shown on the UI
window.inboxStore?.dispatch(conversationActions.conversationRemoved(conversation.id)); if (conversation.isPrivate()) {
conversation.set('active_at', undefined);
await conversation.commit();
} else {
await removeConversation(id);
this.conversations.remove(conversation);
if (window.inboxStore) {
window.inboxStore?.dispatch(conversationActions.conversationRemoved(conversation.id));
window.inboxStore?.dispatch(
conversationActions.conversationChanged(conversation.id, conversation.getProps())
);
}
} }
} }

Loading…
Cancel
Save