Skip to content

Commit

Permalink
fix leaving + clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
atomrc committed Oct 10, 2023
1 parent 9857a07 commit 23922e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/script/conversation/ConversationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1752,13 +1752,13 @@ export class ConversationRepository {
/**
* Remove the current user from a conversation.
*
* @param conversationEntity Conversation to remove user from
* @param conversation Conversation to remove user from
* @param clearContent Should we clear the conversation content from the database?
* @returns Resolves when user was removed from the conversation
*/
public async leaveConversation(conversationEntity: Conversation, {localOnly = false} = {}) {
public async leaveConversation(conversation: Conversation, {localOnly = false} = {}) {
const userQualifiedId = this.userState.self().qualifiedId;
return this.removeMember(conversationEntity, userQualifiedId, {localOnly});
return this.removeMember(conversation, userQualifiedId, {localOnly});
}

/**
Expand Down
13 changes: 8 additions & 5 deletions src/script/view_model/ActionsViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,25 +264,28 @@ export class ActionsViewModel {
return this.connectionRepository.ignoreRequest(userEntity);
};

readonly leaveConversation = (conversationEntity: Conversation): Promise<void> => {
if (!conversationEntity) {
readonly leaveConversation = (conversation: Conversation): Promise<void> => {
if (!conversation) {
return Promise.reject();
}

return new Promise(resolve => {
PrimaryModal.show(PrimaryModal.type.OPTION, {
primaryAction: {
action: async (clearContent = false) => {
await this.conversationRepository.leaveConversation(conversationEntity, {clearContent});
await this.conversationRepository.leaveConversation(conversation);
if (clearContent) {
await this.conversationRepository.clearConversation(conversation);
}
resolve();
},
text: t('modalConversationLeaveAction'),
},
text: {
closeBtnLabel: t('modalConversationLeaveMessageCloseBtn', conversationEntity.display_name()),
closeBtnLabel: t('modalConversationLeaveMessageCloseBtn', conversation.display_name()),
message: t('modalConversationLeaveMessage'),
option: t('modalConversationLeaveOption'),
title: t('modalConversationLeaveHeadline', conversationEntity.display_name()),
title: t('modalConversationLeaveHeadline', conversation.display_name()),
},
});
});
Expand Down

0 comments on commit 23922e1

Please sign in to comment.