mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-27 05:41:23 +00:00
feat(ios): open notification taps on the owning hub
Push payloads do not name a hub, so a tap always opened the session against the active hub. With several paired hubs, a session from another hub then failed to load until the user switched hubs by hand. When the active hub's list does not know the session, the tap now looks it up with GET /api/sessions/:id. Hubs are tried in the same active-first order, and 404/403 have the same meaning, as for the notification actions. If another hub owns the session, the app switches to it first; the new home screen then opens the chat. A miss or an unreachable hub opens against the active hub, as before. Single-hub installs skip the lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5942b427a9
commit
b534a96f2f
@@ -46,7 +46,8 @@ final class AppModel {
|
||||
var infoNotice: String?
|
||||
/// Session targeted by a notification tap (Android
|
||||
/// `pendingOpenSessionId`): the home screen consumes it into its
|
||||
/// navigation path against the active hub.
|
||||
/// navigation path against the active hub (switched to the owner first,
|
||||
/// see ``openNotificationTarget(sessionId:hubUrl:)``).
|
||||
var pendingOpenSessionId: String?
|
||||
|
||||
// `let` storage is inert under @Observable (no annotation needed).
|
||||
@@ -78,7 +79,12 @@ final class AppModel {
|
||||
credentialStore: credentialStore,
|
||||
performer: performer,
|
||||
openChatSessionId: { [weak self] in self?.session?.openChatSessionId },
|
||||
openSession: { [weak self] sessionId in self?.pendingOpenSessionId = sessionId }
|
||||
activeHubKnowsSession: { [weak self] sessionId in
|
||||
self?.session?.sessionStore.sessions.contains { $0.id == sessionId } ?? false
|
||||
},
|
||||
openSession: { [weak self] sessionId, hubUrl in
|
||||
self?.openNotificationTarget(sessionId: sessionId, hubUrl: hubUrl)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
@@ -151,6 +157,15 @@ final class AppModel {
|
||||
}
|
||||
}
|
||||
|
||||
/// Notification tap: a located owning hub becomes active first, so the
|
||||
/// new home screen consumes the target (`HomeView` is keyed by hub).
|
||||
func openNotificationTarget(sessionId: String, hubUrl: String?) {
|
||||
if let hubUrl, registry.hubs.contains(hubUrl), hasCredentials(for: hubUrl) {
|
||||
switchHub(to: hubUrl)
|
||||
}
|
||||
pendingOpenSessionId = sessionId
|
||||
}
|
||||
|
||||
// MARK: - Deep links (hapicompanion://bind)
|
||||
|
||||
/// Routes a parsed bind link: already-paired hubs just switch (with a
|
||||
|
||||
Reference in New Issue
Block a user