Skip to content
Closed
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
9 changes: 9 additions & 0 deletions NextcloudTalk/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import SwiftUI
public var chatController: NCChatController
public var highlightMessageId = 0
public var presentThreadOnAppear = 0
public var presentedThreadNavigationController: NCNavigationController?

// MARK: - Private var
private var hasPresentedLobby = false
Expand Down Expand Up @@ -1154,6 +1155,7 @@ import SwiftUI
let navController = NCNavigationController(rootViewController: chatViewController)
navController.presentationController?.delegate = chatViewController
self.present(navController, animated: true)
presentedThreadNavigationController = navController
}

// MARK: - Voice message player
Expand Down Expand Up @@ -1814,6 +1816,13 @@ import SwiftUI
self.chatController.clearHistoryAndResetChatController()
self.hasRequestedInitialHistory = false
self.chatController.getInitialChatHistory()

// If a thread view is presented, we close it
if self.presentedViewController == presentedThreadNavigationController,
let threadViewController = presentedThreadNavigationController?.viewControllers.first as? ChatViewController {
threadViewController.leaveChat()
threadViewController.dismiss(animated: true)
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions NextcloudTalk/Chat/NCChatController.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ - (void)removeAllStoredMessagesAndChatBlocks
NSPredicate *query = [NSPredicate predicateWithFormat:@"accountId = %@ AND token = %@", _account.accountId, _room.token];
[realm deleteObjects:[NCChatMessage objectsWithPredicate:query]];
[realm deleteObjects:[NCChatBlock objectsWithPredicate:query]];
NSPredicate *threadsQuery = [NSPredicate predicateWithFormat:@"accountId = %@ AND roomToken = %@", _account.accountId, _room.token];
[realm deleteObjects:[NCThread objectsWithPredicate:threadsQuery]];
}];
}

Expand Down
Loading