Skip to content

Commit

Permalink
Merge pull request #4316 from tloncorp/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesacklin authored Jan 8, 2025
2 parents fbee4ec + 6d6ecac commit 93dbcf7
Show file tree
Hide file tree
Showing 185 changed files with 5,182 additions and 3,739 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ env.tag }}
ssh-key: ${{ secrets.DEPLOY_KEY }}
- uses: actions/download-artifact@v3
with:
name: "ui-dist-new"
Expand Down
2 changes: 1 addition & 1 deletion apps/tlon-mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
compileSdk rootProject.ext.compileSdkVersion
versionCode 108
versionName "5.0.0"
versionName "5.0.2"

buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
}
Expand Down
20 changes: 16 additions & 4 deletions apps/tlon-mobile/ios/Landscape.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
638753092CC7036C003942F5 /* ShortcutsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638753072CC7036C003942F5 /* ShortcutsManager.swift */; };
63A5A04E2CD05CB900928EED /* ChannelEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63A5A04D2CD05CB600928EED /* ChannelEntity.swift */; };
63A5A04F2CD05CB900928EED /* ChannelEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63A5A04D2CD05CB600928EED /* ChannelEntity.swift */; };
63CF1DB92D07665B00C0F34E /* ActivityEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CF1DB82D07665700C0F34E /* ActivityEvent.swift */; };
63CF1DBA2D07665B00C0F34E /* ActivityEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CF1DB82D07665700C0F34E /* ActivityEvent.swift */; };
63CF1DBB2D07665B00C0F34E /* ActivityEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CF1DB82D07665700C0F34E /* ActivityEvent.swift */; };
63CF1DBC2D07665B00C0F34E /* ActivityEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CF1DB82D07665700C0F34E /* ActivityEvent.swift */; };
63CF1DBD2D07665B00C0F34E /* ActivityEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63CF1DB82D07665700C0F34E /* ActivityEvent.swift */; };
63E27E0B2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63E27E0A2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift */; };
63E27E0C2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63E27E0A2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift */; };
63E27E0D2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63E27E0A2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift */; };
Expand Down Expand Up @@ -254,6 +259,7 @@
6374ACFC2C4ACD7500E637C0 /* Login.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Login.swift; sourceTree = "<group>"; };
638753072CC7036C003942F5 /* ShortcutsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsManager.swift; sourceTree = "<group>"; };
63A5A04D2CD05CB600928EED /* ChannelEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelEntity.swift; sourceTree = "<group>"; };
63CF1DB82D07665700C0F34E /* ActivityEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityEvent.swift; sourceTree = "<group>"; };
63E27E0A2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Alamofire+sessionWithSharedCookieStorage.swift"; sourceTree = "<group>"; };
63E27E122C5AF5B8008ACB45 /* HTTPCookieStorage+forwardChanges.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "HTTPCookieStorage+forwardChanges.swift"; path = "Landscape/HTTPCookieStorage+forwardChanges.swift"; sourceTree = "<group>"; };
63EC5CBF2CD049540098C343 /* SQLiteDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLiteDB.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -449,6 +455,7 @@
63E7040D2C540FD6006CF214 /* Models */ = {
isa = PBXGroup;
children = (
63CF1DB82D07665700C0F34E /* ActivityEvent.swift */,
709FC0EC2AC1E25D00B0644D /* Club.swift */,
700B635C2A71DFE90017F40F /* Contact.swift */,
70D3866A2A60A38400AFB46E /* Group.swift */,
Expand Down Expand Up @@ -1217,6 +1224,7 @@
70D3865B2A609BFC00AFB46E /* PocketAPI.swift in Sources */,
70D386582A609BFC00AFB46E /* PushNotificationManager.swift in Sources */,
63E27E0B2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift in Sources */,
63CF1DBC2D07665B00C0F34E /* ActivityEvent.swift in Sources */,
700B635D2A71DFE90017F40F /* Contact.swift in Sources */,
70EAEAB92A57CE2A00FE96E4 /* UrbitModule.m in Sources */,
70D386672A60A37000AFB46E /* INPerson+Extension.swift in Sources */,
Expand Down Expand Up @@ -1258,6 +1266,7 @@
630DE0CB2C51A8780053603B /* Error+isAFTimeout.swift in Sources */,
630DE0CC2C51A8780053603B /* PushNotificationManager.swift in Sources */,
630DE0CD2C51A8780053603B /* Yarn.swift in Sources */,
63CF1DBA2D07665B00C0F34E /* ActivityEvent.swift in Sources */,
630DE0CE2C51A8780053603B /* GroupChannelStore.swift in Sources */,
63E27E0E2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift in Sources */,
630DE0CF2C51A8780053603B /* PocketUserAPI.swift in Sources */,
Expand Down Expand Up @@ -1290,6 +1299,7 @@
630DE0B72C51A0F80053603B /* Error+isAFTimeout.swift in Sources */,
632793B62C4ADE9800F942B1 /* PushNotificationManager.swift in Sources */,
632793C22C4AE4FA00F942B1 /* Yarn.swift in Sources */,
63CF1DBD2D07665B00C0F34E /* ActivityEvent.swift in Sources */,
632793C92C4AE7C900F942B1 /* GroupChannelStore.swift in Sources */,
63E27E0D2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift in Sources */,
632793C62C4AE56F00F942B1 /* PocketUserAPI.swift in Sources */,
Expand Down Expand Up @@ -1324,6 +1334,7 @@
70DBBFF02B7C60B50021EA96 /* PushNotificationManager.swift in Sources */,
63E27E0C2C5AF26C008ACB45 /* Alamofire+sessionWithSharedCookieStorage.swift in Sources */,
70DBBFF12B7C60B50021EA96 /* Contact.swift in Sources */,
63CF1DB92D07665B00C0F34E /* ActivityEvent.swift in Sources */,
70DBBFF22B7C60B50021EA96 /* UrbitModule.m in Sources */,
70DBBFF32B7C60B50021EA96 /* INPerson+Extension.swift in Sources */,
70DBBFF42B7C60B50021EA96 /* Error+logWithDomain.swift in Sources */,
Expand Down Expand Up @@ -1365,6 +1376,7 @@
70F99A9B2B2D336500D77256 /* INPerson+Extension.swift in Sources */,
70F99AAB2B2D337600D77256 /* UserDefaultsStore.swift in Sources */,
70F99A982B2D2B6E00D77256 /* YarnTests.swift in Sources */,
63CF1DBB2D07665B00C0F34E /* ActivityEvent.swift in Sources */,
632793C02C4AE4B500F942B1 /* Error+isAFTimeout.swift in Sources */,
70F99AA92B2D337600D77256 /* GroupChannelStore.swift in Sources */,
70F99A9F2B2D336800D77256 /* Group.swift in Sources */,
Expand Down Expand Up @@ -1427,7 +1439,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1465,7 +1477,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1689,7 +1701,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1732,7 +1744,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
90 changes: 57 additions & 33 deletions apps/tlon-mobile/ios/Notifications/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,40 @@ class NotificationService: UNNotificationServiceExtension {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

Task { [weak bestAttemptContent] in
let parsedNotification = await PushNotificationManager.parseNotificationUserInfo(request.content.userInfo)
switch parsedNotification {
case let .notify(yarn):
let (mutatedContent, messageIntent) = await PushNotificationManager.buildNotificationWithIntent(
yarn: yarn,
content: bestAttemptContent ?? UNMutableNotificationContent()
)

if let messageIntent {
do {
let interaction = INInteraction(intent: messageIntent, response: nil)
interaction.direction = .incoming
try await interaction.donate()
} catch {
print("Error donating interaction for notification sender details: \(error)")
}
}

contentHandler(mutatedContent)
return

case let .failedFetchContents(err):
packErrorOnNotification(err)
contentHandler(bestAttemptContent!)
return

case .invalid:
fallthrough

case .dismiss:
contentHandler(bestAttemptContent!)
return
Task { [weak bestAttemptContent] in
let parsedNotification = await PushNotificationManager.parseNotificationUserInfo(request.content.userInfo)
switch parsedNotification {
case let .yarn(yarn, activityEvent):
var notifContent = await handle(yarn)
if let activityEvent {
if let dm = activityEvent.dmPost {
let mutableNotifContent = notifContent.mutableCopy() as! UNMutableNotificationContent
// convert to JSON because `userInfo` needs NSSecureCoding
mutableNotifContent.userInfo["dmPost"] = try! dm.asJson()
notifContent = mutableNotifContent
} else if let post = activityEvent.post {
let mutableNotifContent = notifContent.mutableCopy() as! UNMutableNotificationContent
// convert to JSON because `userInfo` needs NSSecureCoding
mutableNotifContent.userInfo["post"] = try! post.asJson()
notifContent = mutableNotifContent
}
}
contentHandler(notifContent)
return

case let .failedFetchContents(err):
packErrorOnNotification(err)
contentHandler(bestAttemptContent!)
return

case .invalid:
fallthrough

case .dismiss:
contentHandler(bestAttemptContent!)
return
}
}
}

/** Appends an error onto the `bestAttemptContent` payload; does *not* attempt to complete the notification request. */
Expand All @@ -61,6 +60,24 @@ class NotificationService: UNNotificationServiceExtension {
contentHandler(bestAttemptContent)
}
}

private func handle(_ renderable: UNNotificationRenderable) async -> UNNotificationContent {
let (mutatedContent, messageIntent) = await renderable.render(
to: bestAttemptContent ?? UNMutableNotificationContent()
)

if let messageIntent {
do {
let interaction = INInteraction(intent: messageIntent, response: nil)
interaction.direction = .incoming
try await interaction.donate()
} catch {
print("Error donating interaction for notification sender details: \(error)")
}
}

return mutatedContent
}
}

extension Error {
Expand All @@ -70,3 +87,10 @@ extension Error {
print(domain, self)
}
}

extension Encodable {
func asJson() throws -> Any {
let data = try JSONEncoder().encode(self)
return try JSONSerialization.jsonObject(with: data, options: [])
}
}
Loading

0 comments on commit 93dbcf7

Please sign in to comment.