diff --git a/IceCubesApp.xcodeproj/project.pbxproj b/IceCubesApp.xcodeproj/project.pbxproj index fbc7218c..f7071df7 100644 --- a/IceCubesApp.xcodeproj/project.pbxproj +++ b/IceCubesApp.xcodeproj/project.pbxproj @@ -80,6 +80,11 @@ 9FD542E72962D2FF0045321A /* Lists in Frameworks */ = {isa = PBXBuildFile; productRef = 9FD542E62962D2FF0045321A /* Lists */; }; 9FE151A6293C90F900E9683D /* IconSelectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FE151A5293C90F900E9683D /* IconSelectorView.swift */; }; 9FE3DB57296FEFCA00628CB0 /* AppAccount in Frameworks */ = {isa = PBXBuildFile; productRef = 9FE3DB56296FEFCA00628CB0 /* AppAccount */; }; + 9FFF677C299B7B2C00FE700A /* Notifications in Frameworks */ = {isa = PBXBuildFile; productRef = 9FFF677B299B7B2C00FE700A /* Notifications */; }; + 9FFF677E299B7D2800FE700A /* Status in Frameworks */ = {isa = PBXBuildFile; productRef = 9FFF677D299B7D2800FE700A /* Status */; }; + 9FFF6780299B7D2B00FE700A /* DesignSystem in Frameworks */ = {isa = PBXBuildFile; productRef = 9FFF677F299B7D2B00FE700A /* DesignSystem */; }; + 9FFF6782299B7D3A00FE700A /* Account in Frameworks */ = {isa = PBXBuildFile; productRef = 9FFF6781299B7D3A00FE700A /* Account */; }; + 9FFF6784299B7D4400FE700A /* LRUCache in Frameworks */ = {isa = PBXBuildFile; productRef = 9FFF6783299B7D4400FE700A /* LRUCache */; }; C9B22677297F6C2E001F9EFE /* ContentSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B22676297F6C2E001F9EFE /* ContentSettingsView.swift */; }; D08A9C3529956CFA00204A4A /* SwipeActionsSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D08A9C3429956CFA00204A4A /* SwipeActionsSettingsView.swift */; }; E92817FA298443D600875FD1 /* Models in Frameworks */ = {isa = PBXBuildFile; productRef = E92817F9298443D600875FD1 /* Models */; }; @@ -248,9 +253,14 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 9FFF677C299B7B2C00FE700A /* Notifications in Frameworks */, 9F7D93942980063100EE6B7A /* AppAccount in Frameworks */, + 9FFF6780299B7D2B00FE700A /* DesignSystem in Frameworks */, + 9FFF6784299B7D4400FE700A /* LRUCache in Frameworks */, 9F2A5428296AB683009B2D7C /* Models in Frameworks */, + 9FFF6782299B7D3A00FE700A /* Account in Frameworks */, 9F2A5426296AB67E009B2D7C /* KeychainSwift in Frameworks */, + 9FFF677E299B7D2800FE700A /* Status in Frameworks */, 9F2A5424296AB67A009B2D7C /* Env in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -526,6 +536,11 @@ 9F2A5425296AB67E009B2D7C /* KeychainSwift */, 9F2A5427296AB683009B2D7C /* Models */, 9F7D93932980063100EE6B7A /* AppAccount */, + 9FFF677B299B7B2C00FE700A /* Notifications */, + 9FFF677D299B7D2800FE700A /* Status */, + 9FFF677F299B7D2B00FE700A /* DesignSystem */, + 9FFF6781299B7D3A00FE700A /* Account */, + 9FFF6783299B7D4400FE700A /* LRUCache */, ); productName = IceCubesNotifications; productReference = 9F2A5416296AB631009B2D7C /* IceCubesNotifications.appex */; @@ -895,7 +910,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp.IceCubesNotifications"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -925,7 +940,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp.IceCubesNotifications"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -956,7 +971,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp.IceCubesShareExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -986,7 +1001,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp.IceCubesShareExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1152,7 +1167,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; @@ -1204,7 +1219,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; @@ -1237,7 +1252,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp.IceCubesActionExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1268,7 +1283,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.9; + MARKETING_VERSION = 1.5.0; PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID_PREFIX).IceCubesApp.IceCubesActionExtension"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1473,6 +1488,27 @@ isa = XCSwiftPackageProductDependency; productName = AppAccount; }; + 9FFF677B299B7B2C00FE700A /* Notifications */ = { + isa = XCSwiftPackageProductDependency; + productName = Notifications; + }; + 9FFF677D299B7D2800FE700A /* Status */ = { + isa = XCSwiftPackageProductDependency; + productName = Status; + }; + 9FFF677F299B7D2B00FE700A /* DesignSystem */ = { + isa = XCSwiftPackageProductDependency; + productName = DesignSystem; + }; + 9FFF6781299B7D3A00FE700A /* Account */ = { + isa = XCSwiftPackageProductDependency; + productName = Account; + }; + 9FFF6783299B7D4400FE700A /* LRUCache */ = { + isa = XCSwiftPackageProductDependency; + package = 065FA1FC29866CD600012EA0 /* XCRemoteSwiftPackageReference "LRUCache" */; + productName = LRUCache; + }; E92817F9298443D600875FD1 /* Models */ = { isa = XCSwiftPackageProductDependency; productName = Models; diff --git a/IceCubesApp/App/IceCubesApp.swift b/IceCubesApp/App/IceCubesApp.swift index 6ae9ee7c..b62f00d0 100644 --- a/IceCubesApp/App/IceCubesApp.swift +++ b/IceCubesApp/App/IceCubesApp.swift @@ -57,10 +57,20 @@ struct IceCubesApp: App { .edgesIgnoringSafeArea(.bottom) .background(TransparentBackground()) }) - .onChange(of: pushNotificationsService.handleNotification) { notification in + .onChange(of: pushNotificationsService.handledNotification) { notification in if notification != nil { - pushNotificationsService.handleNotification = nil - selectedTab = .notifications + pushNotificationsService.handledNotification = nil + if appAccountsManager.currentAccount.oauthToken?.accessToken != notification?.account.token.accessToken, + let account = appAccountsManager.availableAccounts.first(where: + { $0.oauthToken?.accessToken == notification?.account.token.accessToken }) { + appAccountsManager.currentAccount = account + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + selectedTab = .notifications + pushNotificationsService.handledNotification = notification + } + } else { + selectedTab = .notifications + } } } } diff --git a/IceCubesApp/App/Tabs/NotificationTab.swift b/IceCubesApp/App/Tabs/NotificationTab.swift index e11f6686..0d9008e2 100644 --- a/IceCubesApp/App/Tabs/NotificationTab.swift +++ b/IceCubesApp/App/Tabs/NotificationTab.swift @@ -54,14 +54,14 @@ struct NotificationsTab: View { routerPath.path = [] } } - .onChange(of: pushNotificationsService.handleNotification) { notification in - if let notification, let type = notification.supportedType { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + .onChange(of: pushNotificationsService.handledNotification) { notification in + if let notification, let type = notification.notification.supportedType { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { switch type { case .follow, .follow_request: - routerPath.navigate(to: .accountDetailWithAccount(account: notification.account)) + routerPath.navigate(to: .accountDetailWithAccount(account: notification.notification.account)) default: - if let status = notification.status { + if let status = notification.notification.status { routerPath.navigate(to: .statusDetailWithStatus(status: status)) } } diff --git a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings index 4abf3773..1825155f 100644 --- a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings @@ -333,6 +333,14 @@ "notifications.tab.all" = "Totes"; "notifications.tab.mentions" = "Mencions"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Federada"; "timeline.latest" = "Jump to Latest"; diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 1bfd579e..a3a88252 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -331,6 +331,14 @@ "notifications.tab.all" = "Alle"; "notifications.tab.mentions" = "ErwΓ€hnungen"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "FΓΆderiert"; "timeline.latest" = "Zum Neuesten springen"; diff --git a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings index 8f903a3a..fc320dd5 100644 --- a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings @@ -336,6 +336,14 @@ "notifications.tab.all" = "All"; "notifications.tab.mentions" = "Mentions"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Federated"; "timeline.latest" = "Jump to Latest"; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index c5c70652..328fdaef 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -335,6 +335,14 @@ "notifications.tab.all" = "All"; "notifications.tab.mentions" = "Mentions"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Federated"; "timeline.latest" = "Jump to Latest"; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index 6d8a36ef..dc36ac29 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -335,6 +335,14 @@ "notifications.tab.all" = "Todo"; "notifications.tab.mentions" = "Menciones"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Federado"; "timeline.latest" = "Jump to Latest"; diff --git a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings index 3182cc0c..44bf18c9 100644 --- a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings @@ -337,6 +337,14 @@ "notifications.tab.all" = "Guztia"; "notifications.tab.mentions" = "Aipamenak"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Federatua"; "timeline.latest" = "Egin salto berrienera"; diff --git a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings index 0d7c0ff4..93a381f9 100644 --- a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings @@ -330,6 +330,14 @@ "notifications.tab.all" = "Tout"; "notifications.tab.mentions" = "Mentions"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "FΓ©dΓ©rΓ©"; "timeline.latest" = "Aller au plus rΓ©cent"; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index fef9992a..96cdcf2e 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -335,6 +335,14 @@ "notifications.tab.all" = "Tutto"; "notifications.tab.mentions" = "Menzioni"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Federazione"; "timeline.latest" = "Vai all'ultimo post"; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index b6926a92..3bd972ff 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -334,6 +334,14 @@ "notifications.tab.all" = "全て"; "notifications.tab.mentions" = "θΏ”δΏ‘"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "ι€£εˆ"; "timeline.latest" = "ζœ€ζ–°ζƒ…ε ±γΎγ§γ‚Έγƒ£γƒ³γƒ—"; diff --git a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings index 688938d1..f61d4796 100644 --- a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings @@ -336,6 +336,14 @@ "notifications.tab.all" = "λͺ¨λ“  μ•Œλ¦Ό"; "notifications.tab.mentions" = "μ–ΈκΈ‰"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "μ—°ν•©"; "timeline.latest" = "μ΅œμ‹  νƒ€μž„λΌμΈ λ‹€μ‹œ 뢈러였기"; diff --git a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings index c556f97b..c1881af4 100644 --- a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings @@ -334,6 +334,14 @@ "notifications.tab.all" = "Alle"; "notifications.tab.mentions" = "Omtaler"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Federert"; "timeline.latest" = "Jump to Latest"; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index d39a3f5c..018b6641 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -328,6 +328,14 @@ "notifications.tab.all" = "Alle"; "notifications.tab.mentions" = "Vermeldingen"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Gefedereerd"; "timeline.latest" = "Spring naar meest recent"; diff --git a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings index fa82da50..6dfa92e9 100644 --- a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings @@ -331,6 +331,14 @@ "notifications.tab.all" = "Wszystko"; "notifications.tab.mentions" = "Wzmianki"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "StrumieΕ„ globalny"; "timeline.latest" = "Najnowsze posty"; diff --git a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings index 3658e4e9..5c53c1a1 100644 --- a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -334,6 +334,14 @@ "notifications.tab.all" = "Todos"; "notifications.tab.mentions" = "Mençáes"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Linha global"; "timeline.latest" = "Jump to Latest"; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index 51a59ebd..ffbf47c0 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -330,6 +330,14 @@ "notifications.tab.all" = "TamamΔ±"; "notifications.tab.mentions" = "Bahsetmeler"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "Birleştirilmiş"; "timeline.latest" = "Jump to Latest"; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index eb2dd790..3e93e785 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -335,6 +335,14 @@ "notifications.tab.all" = "全部"; "notifications.tab.mentions" = "提及"; +"notifications.label.status.push" = "πŸ–ŠοΈ Posted: "; +"notifications.label.reblog.push" = "πŸš€ Boosted: "; +"notifications.label.follow.push" = "πŸ‘‹ Followed you: "; +"notifications.label.follow-request.push" = "πŸ”’ Requested to follow you: "; +"notifications.label.favorite.push" = "⭐️ Starred: "; +"notifications.label.poll.push" = "πŸ“ˆ Poll ended: "; +"notifications.label.update.push" = "Updated: "; + // MARK: Package: Timeline "timeline.federated" = "θ·¨η«™"; "timeline.latest" = "θ·³θ½¬εˆ°ζœ€ζ–°"; diff --git a/IceCubesNotifications/NotificationService.swift b/IceCubesNotifications/NotificationService.swift index 90cc5e7e..ac1100e6 100644 --- a/IceCubesNotifications/NotificationService.swift +++ b/IceCubesNotifications/NotificationService.swift @@ -7,6 +7,7 @@ import UIKit import UserNotifications import Intents import Network +import Notifications @MainActor class NotificationService: UNNotificationServiceExtension { @@ -81,14 +82,16 @@ class NotificationService: UNNotificationServiceExtension { if let image = UIImage(data: data) { try? image.pngData()?.write(to: fileURL) - if let remoteNotification = await toRemoteNotification(localNotification: notification) { - let intent = buildMessageIntent(remoteNotification: remoteNotification, avatarURL: fileURL) + if let remoteNotification = await toRemoteNotification(localNotification: notification), + let type = remoteNotification.supportedType { + let intent = buildMessageIntent(remoteNotification: remoteNotification, + currentUser: bestAttemptContent.userInfo["i"] as? String ?? "", + avatarURL: fileURL) bestAttemptContent = try bestAttemptContent.updating(from: intent) as! UNMutableNotificationContent - if AppAccountsManager.shared.availableAccounts.count > 1 { - let newBody = "\(bestAttemptContent.userInfo["i"] as? String ?? "") \n\(notification.title)\n\(notification.body.escape())" - bestAttemptContent.body = newBody + if type == .mention { + bestAttemptContent.body = notification.body.escape() } else { - let newBody = "\(notification.title)\n\(notification.body.escape())" + let newBody = "\(NSLocalizedString(type.notificationKey(), bundle: .main, comment: ""))\(notification.body.escape())" bestAttemptContent.body = newBody } } else { @@ -121,7 +124,9 @@ class NotificationService: UNNotificationServiceExtension { return nil } - private func buildMessageIntent(remoteNotification: Models.Notification, avatarURL: URL) -> INSendMessageIntent { + private func buildMessageIntent(remoteNotification: Models.Notification, + currentUser: String, + avatarURL: URL) -> INSendMessageIntent { let handle = INPersonHandle(value: remoteNotification.account.id, type: .unknown) let avatar = INImage(url: avatarURL) let sender = INPerson(personHandle: handle, @@ -130,14 +135,29 @@ class NotificationService: UNNotificationServiceExtension { image: avatar, contactIdentifier: nil, customIdentifier: nil) - let intent = INSendMessageIntent(recipients: nil, + var recipents: [INPerson]? + var groupName: INSpeakableString? + if AppAccountsManager.shared.availableAccounts.count > 1 { + let me = INPerson(personHandle: .init(value: currentUser, type: .unknown), + nameComponents: nil, + displayName: currentUser, + image: nil, + contactIdentifier: nil, + customIdentifier: nil) + recipents = [me, sender] + groupName = .init(spokenPhrase: currentUser) + } + let intent = INSendMessageIntent(recipients: recipents, outgoingMessageType: .outgoingMessageText, content: nil, - speakableGroupName: nil, + speakableGroupName: groupName, conversationIdentifier: remoteNotification.account.id, serviceName: nil, sender: sender, attachments: nil) + if groupName != nil { + intent.setImage(avatar, forParameterNamed: \.speakableGroupName) + } return intent } } diff --git a/Packages/Env/Sources/Env/PushNotificationsService.swift b/Packages/Env/Sources/Env/PushNotificationsService.swift index 89d3f60f..a1401f42 100644 --- a/Packages/Env/Sources/Env/PushNotificationsService.swift +++ b/Packages/Env/Sources/Env/PushNotificationsService.swift @@ -6,7 +6,7 @@ import Network import SwiftUI import UserNotifications -public struct PushAccount { +public struct PushAccount: Equatable { public let server: String public let token: OauthToken public let accountName: String? @@ -18,6 +18,11 @@ public struct PushAccount { } } +public struct HandledNotification: Equatable { + public let account: PushAccount + public let notification: Models.Notification +} + @MainActor public class PushNotificationsService: NSObject, ObservableObject { enum Constants { @@ -31,7 +36,8 @@ public class PushNotificationsService: NSObject, ObservableObject { public private(set) var subscriptions: [PushNotificationSubscriptionSettings] = [] @Published public var pushToken: Data? - @Published public var handleNotification: Models.Notification? + + @Published public var handledNotification: HandledNotification? override init() { super.init() @@ -139,7 +145,7 @@ extension PushNotificationsService: UNUserNotificationCenterDelegate { let client = Client(server: account.account.server, oauthToken: account.account.token) let notification: Models.Notification = try await client.get(endpoint: Notifications.notification(id:String(mastodonPushNotification.notificationID))) - self.handleNotification = notification + self.handledNotification = .init(account: account.account, notification: notification) } catch { } } } diff --git a/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift b/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift index 1a296e35..c44843ec 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationTypeExt.swift @@ -3,7 +3,7 @@ import Models import SwiftUI extension Models.Notification.NotificationType { - func label(count: Int) -> LocalizedStringKey { + public func label(count: Int) -> LocalizedStringKey { switch self { case .status: return "notifications.label.status" @@ -23,6 +23,27 @@ extension Models.Notification.NotificationType { return "notifications.label.update" } } + + public func notificationKey() -> String { + switch self { + case .status: + return "notifications.label.status.push" + case .mention: + return "" + case .reblog: + return "notifications.label.reblog.push" + case .follow: + return "notifications.label.follow.push" + case .follow_request: + return "notifications.label.follow-request.push" + case .favourite: + return "notifications.label.favorite.push" + case .poll: + return "notifications.label.poll.push" + case .update: + return "notifications.label.update.push" + } + } func iconName() -> String { switch self {