Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Delta Chat iOS Changelog

## Unreleased

- No longer open last chat when app is restarted


## v2.56.0
2026-07

Expand Down
2 changes: 0 additions & 2 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ class ChatViewController: UIViewController, UITableViewDelegate, UITableViewData

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
AppStateRestorer.shared.storeLastActiveChat(chatId: chatId)
updateScrollDownButtonVisibility()
// things that do not affect the chatview
// and are delayed after the view is displayed
Expand All @@ -534,7 +533,6 @@ class ChatViewController: UIViewController, UITableViewDelegate, UITableViewData

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
AppStateRestorer.shared.resetLastActiveChat()
handleUserVisibility(isVisible: false)
if #available(iOS 26.0, *), let previousValue = wasInteractiveContentPopGestureRecognizerEnabled {
navigationController?.interactiveContentPopGestureRecognizer?.isEnabled = previousValue
Expand Down
7 changes: 0 additions & 7 deletions deltachat-ios/Coordinator/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ class AppCoordinator: NSObject {
showTab(index: chatsTab)
} else {
showTab(index: lastActiveTab)
if let lastActiveChatId = appStateRestorer.restoreLastActiveChatId(), lastActiveTab == chatsTab {
// as getChat() returns an empty object for invalid chatId,
// check that the returned object is actually set up.
if dcContext.getChat(chatId: lastActiveChatId).id == lastActiveChatId {
showChat(chatId: lastActiveChatId, animated: false)
}
}
}
}

Expand Down
27 changes: 0 additions & 27 deletions deltachat-ios/Handler/AppStateRestorer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import UIKit
class AppStateRestorer {

private let lastActiveTabKey = "last_active_tab3"
private let lastActiveChatId = "last_active_chat_id"
private let offsetKey = 11

// UserDefaults returns 0 by default which conflicts with tab 0 -> therefore we map our tab indexes by adding an offsetKey
Expand All @@ -30,32 +29,6 @@ class AppStateRestorer {

func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
let activeTab = tabBarController.selectedIndex + offsetKey

if let tab = Tab(rawValue: activeTab), tab != .chatTab {
resetLastActiveChat()
}

UserDefaults.standard.set(activeTab, forKey: lastActiveTabKey)
}

private func storeChat(chatId: Int?) {
let value = chatId ?? -1
UserDefaults.standard.set(value, forKey: lastActiveChatId)
}

func storeLastActiveChat(chatId: Int) {
storeChat(chatId: chatId)
}

func resetLastActiveChat() {
storeChat(chatId: nil)
}

func restoreLastActiveChatId() -> Int? {
let restoredChatId = UserDefaults.standard.integer(forKey: lastActiveChatId)
if restoredChatId == -1 || restoredChatId == 0 {
return nil
}
return restoredChatId
}
}
Loading