Skip to content

Commit

Permalink
Remove chats from widget if removing them (#2457)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Jan 2, 2025
1 parent 19ae52f commit 6bd2993
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,9 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
guard let self else { return }
// remove message observers early to avoid careless calls to dcContext methods
self.dcContext.deleteChat(chatId: self.chatId)
if #available(iOS 15.0, *) {
UserDefaults.shared?.removeChatFromHomescreenWidget(accountId: dcContext.id, chatId: chatId)
}
self.navigationController?.popViewController(animated: true)
})
}
Expand Down
3 changes: 3 additions & 0 deletions deltachat-ios/Controller/ContactDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ class ContactDetailViewController: UITableViewController {
return
}
viewModel.context.deleteChat(chatId: viewModel.chatId)
if #available(iOS 15.0, *) {
UserDefaults.shared?.removeChatFromHomescreenWidget(accountId: viewModel.context.id, chatId: viewModel.chatId)
}
NotificationManager.removeNotificationsForChat(dcContext: viewModel.context, chatId: viewModel.chatId)
INInteraction.delete(with: ["\(viewModel.context.id).\(viewModel.chatId)"])

Expand Down
3 changes: 3 additions & 0 deletions deltachat-ios/Controller/GroupChatDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ class GroupChatDetailViewController: UIViewController {
private func deleteChat() {
dcContext.deleteChat(chatId: chatId)
NotificationManager.removeNotificationsForChat(dcContext: dcContext, chatId: chatId)
if #available(iOS 15.0, *) {
UserDefaults.shared?.removeChatFromHomescreenWidget(accountId: dcContext.id, chatId: chatId)
}
INInteraction.delete(with: ["\(dcContext.id).\(chatId)"])
navigationController?.popViewControllers(viewsToPop: 2, animated: true)
}
Expand Down
3 changes: 3 additions & 0 deletions deltachat-ios/ViewModel/ChatListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ class ChatListViewModel: NSObject {

func deleteChat(chatId: Int) {
dcContext.deleteChat(chatId: chatId)
if #available(iOS 15.0, *) {
UserDefaults.shared?.removeChatFromHomescreenWidget(accountId: dcContext.id, chatId: chatId)
}
NotificationManager.removeNotificationsForChat(dcContext: dcContext, chatId: chatId)
INInteraction.delete(with: ["\(dcContext.id).\(chatId)"])
}
Expand Down

0 comments on commit 6bd2993

Please sign in to comment.