Changeset View
Changeset View
Standalone View
Standalone View
native/ios/Comm/AppDelegate.mm
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#import <ReactCommon/RCTTurboModuleManager.h> | #import <ReactCommon/RCTTurboModuleManager.h> | ||||
#import <RNReanimated/REAInitializer.h> | #import <RNReanimated/REAInitializer.h> | ||||
#import <UserNotifications/UserNotifications.h> | #import <UserNotifications/UserNotifications.h> | ||||
NSString *const backgroundNotificationTypeKey = @"backgroundNotifType"; | NSString *const backgroundNotificationTypeKey = @"backgroundNotifType"; | ||||
NSString *const setUnreadStatusKey = @"setUnreadStatus"; | NSString *const setUnreadStatusKey = @"setUnreadStatus"; | ||||
NSString *const threadIDKey = @"threadID"; | |||||
@interface AppDelegate () < | @interface AppDelegate () < | ||||
RCTCxxBridgeDelegate, | RCTCxxBridgeDelegate, | ||||
RCTTurboModuleManagerDelegate> { | RCTTurboModuleManagerDelegate> { | ||||
} | } | ||||
@end | @end | ||||
@implementation AppDelegate | @implementation AppDelegate | ||||
▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | TemporaryMessageStorage *temporaryStorage = | ||||
[[TemporaryMessageStorage alloc] init]; | [[TemporaryMessageStorage alloc] init]; | ||||
NSArray<NSString *> *messages = [temporaryStorage readAndClearMessages]; | NSArray<NSString *> *messages = [temporaryStorage readAndClearMessages]; | ||||
for (NSString *message in messages) { | for (NSString *message in messages) { | ||||
std::string messageInfos = std::string([message UTF8String]); | std::string messageInfos = std::string([message UTF8String]); | ||||
comm::GlobalDBSingleton::instance.scheduleOrRun([messageInfos]() mutable { | comm::GlobalDBSingleton::instance.scheduleOrRun([messageInfos]() mutable { | ||||
comm::MessageOperationsUtilities::storeMessageInfos(messageInfos); | comm::MessageOperationsUtilities::storeMessageInfos(messageInfos); | ||||
}); | }); | ||||
} | } | ||||
TemporaryMessageStorage *temporaryRescindsStorage = | |||||
[[TemporaryMessageStorage alloc] initForRescinds]; | |||||
NSArray<NSString *> *rescindMessages = | |||||
[temporaryRescindsStorage readAndClearMessages]; | |||||
for (NSString *rescindMessage in rescindMessages) { | |||||
NSData *binaryRescindMessage = | |||||
[rescindMessage dataUsingEncoding:NSUTF8StringEncoding]; | |||||
NSError *jsonError = nil; | |||||
NSDictionary *rescindPayload = | |||||
[NSJSONSerialization JSONObjectWithData:binaryRescindMessage | |||||
options:0 | |||||
error:&jsonError]; | |||||
if (jsonError) { | |||||
comm::Logger::log( | |||||
"Failed to deserialize persisted rescind payload. Details: " + | |||||
std::string([jsonError.localizedDescription UTF8String])); | |||||
continue; | |||||
} | |||||
if (!(rescindPayload[setUnreadStatusKey] && rescindPayload[threadIDKey])) { | |||||
continue; | |||||
} | |||||
std::string threadID = | |||||
std::string([rescindPayload[threadIDKey] UTF8String]); | |||||
comm::GlobalDBSingleton::instance.scheduleOrRun([threadID]() mutable { | |||||
comm::ThreadOperations::updateSQLiteUnreadStatus(threadID, false); | |||||
}); | |||||
} | |||||
} | } | ||||
// Copied from | // Copied from | ||||
// ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp | // ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp | ||||
static ::hermes::vm::RuntimeConfig | static ::hermes::vm::RuntimeConfig | ||||
makeRuntimeConfig(::hermes::vm::gcheapsize_t heapSizeMB) { | makeRuntimeConfig(::hermes::vm::gcheapsize_t heapSizeMB) { | ||||
namespace vm = ::hermes::vm; | namespace vm = ::hermes::vm; | ||||
auto gcConfigBuilder = | auto gcConfigBuilder = | ||||
Show All 18 Lines |