Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove a group from conversation list after leaving it #18227

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
"conversationDetailsActionDevices": "Devices",
"conversationDetailsActionGuestOptions": "Guests",
"conversationDetailsActionLeave": "Leave group",
"conversationDetailsActionRemove": "Remove group",
"conversationDetailsActionNotifications": "Notifications",
"conversationDetailsActionServicesOptions": "Services",
"conversationDetailsActionTimedMessages": "Self-deleting messages",
Expand Down Expand Up @@ -1057,6 +1058,9 @@
"modalConversationRemoveGuestsOrServicesAction": "Disable",
"modalConversationRemoveHeadline": "Remove?",
"modalConversationRemoveMessage": "{{user}} won’t be able to send or receive messages in this conversation.",
"modalConversationRemoveGroupAction": "Remove",
"modalConversationRemoveGroupHeadline": "Remove group conversation?",
"modalConversationRemoveGroupMessage": "This will delete the group on this device. There is no option to restore the content.",
"modalConversationRemoveServicesHeadline": "Disable services access?",
"modalConversationRemoveServicesMessage": "Current services will be removed from the conversation. New services will not be allowed.",
"modalConversationRevokeLinkAction": "Revoke link",
Expand Down
2 changes: 1 addition & 1 deletion src/script/conversation/ConversationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ export class ConversationRepository {
}
}

private readonly deleteConversationLocally = async (conversationId: QualifiedId, skipNotification: boolean) => {
public readonly deleteConversationLocally = async (conversationId: QualifiedId, skipNotification: boolean) => {
const conversationEntity = this.conversationState.findConversation(conversationId);
if (!conversationEntity) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/script/entity/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export class Conversation {
}
});

this.isCreatedBySelf = ko.pureComputed(() => this.selfUser().id === this.creator && !this.isSelfUserRemoved());
this.isCreatedBySelf = ko.pureComputed(() => this.selfUser()?.id === this.creator && !this.isSelfUserRemoved());

this.showNotificationsEverything = ko.pureComputed(() => {
return this.notificationState() === NOTIFICATION_STATE.EVERYTHING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ const getConversationActions = ({
label: t('conversationDetailsActionDelete'),
},
},
{
condition: conversationEntity.isGroup() && conversationEntity.isSelfUserRemoved(),
item: {
click: async () => actionsViewModel.removeConversation(conversationEntity),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing promise wrapper:

Suggested change
click: async () => actionsViewModel.removeConversation(conversationEntity),
click: () => actionsViewModel.removeConversation(conversationEntity),

Icon: Icon.CloseIcon,
identifier: 'do-remove',
label: t('conversationDetailsActionRemove'),
},
},
];

return allMenuElements.filter(menuElement => menuElement.condition).map(menuElement => menuElement.item);
Expand Down
19 changes: 19 additions & 0 deletions src/script/view_model/ActionsViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,25 @@ export class ActionsViewModel {
return Promise.reject();
};

readonly removeConversation = (conversationEntity: Conversation): Promise<void> => {
if (conversationEntity.isGroup() && conversationEntity.isSelfUserRemoved()) {
return new Promise(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to wrap it in promise?

PrimaryModal.show(PrimaryModal.type.CONFIRM, {
primaryAction: {
action: () => this.conversationRepository.deleteConversationLocally(conversationEntity, true),
text: t('modalConversationRemoveGroupAction'),
},
text: {
message: t('modalConversationRemoveGroupMessage'),
title: t('modalConversationRemoveGroupHeadline'),
},
});
});
}

return Promise.reject();
};

getConversationById = async (conversation: QualifiedId): Promise<Conversation> => {
return this.conversationRepository.getConversationById(conversation);
};
Expand Down
Loading