@@ -78,17 +78,23 @@ static void RCTAppendError(NSDictionary *error, NSMutableArray<NSDictionary *> *
78
78
return nil ;
79
79
}
80
80
81
+ static NSString *RCTCreateStorageDirectoryPath (NSString *storageDir) {
82
+ NSString *storageDirectoryPath;
83
+ #if TARGET_OS_TV
84
+ storageDirectoryPath = NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDomainMask, YES ).firstObject ;
85
+ #else
86
+ storageDirectoryPath = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES ).firstObject ;
87
+ #endif
88
+ storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent: RCTStorageDirectory];
89
+ return storageDirectoryPath;
90
+ }
91
+
81
92
static NSString *RCTGetStorageDirectory ()
82
93
{
83
94
static NSString *storageDirectory = nil ;
84
95
static dispatch_once_t onceToken;
85
96
dispatch_once (&onceToken, ^{
86
- #if TARGET_OS_TV
87
- storageDirectory = NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDomainMask, YES ).firstObject ;
88
- #else
89
- storageDirectory = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES ).firstObject ;
90
- #endif
91
- storageDirectory = [storageDirectory stringByAppendingPathComponent: RCTStorageDirectory];
97
+ storageDirectory = RCTCreateStorageDirectoryPath (RCTStorageDirectory);
92
98
});
93
99
return storageDirectory;
94
100
}
@@ -168,6 +174,12 @@ static dispatch_queue_t RCTGetMethodQueue()
168
174
return error ? RCTMakeError (@" Failed to delete storage directory." , error, nil ) : nil ;
169
175
}
170
176
177
+ static void RCTPerformDirectoryMigrationCheck () {
178
+ // NSString *oldRCTStorageDirectory = @"RNCAsyncLocalStorage_V1";
179
+ // NSString *storageDir = RCTCreateStorageDirectoryPath(oldRCTStorageDirectory);
180
+ // printf("%s%s\n", "TESTING: ", [storageDir UTF8String]);
181
+ }
182
+
171
183
#pragma mark - RNCAsyncStorage
172
184
173
185
@implementation RNCAsyncStorage
@@ -179,6 +191,19 @@ @implementation RNCAsyncStorage
179
191
NSMutableDictionary <NSString *, NSString *> *_manifest;
180
192
}
181
193
194
+ + (BOOL )requiresMainQueueSetup {
195
+ return YES ;
196
+ }
197
+
198
+ - (instancetype )init
199
+ {
200
+ if (!(self = [super init ])) {
201
+ return nil ;
202
+ }
203
+ RCTPerformDirectoryMigrationCheck ();
204
+ return self;
205
+ }
206
+
182
207
RCT_EXPORT_MODULE ()
183
208
184
209
- (dispatch_queue_t )methodQueue
@@ -441,7 +466,7 @@ - (BOOL)_passthroughDelegate
441
466
}
442
467
443
468
RCT_EXPORT_METHOD (multiMerge:(NSArray <NSArray <NSString *> *> *)kvPairs
444
- callback:(RCTResponseSenderBlock)callback)
469
+ callback:(RCTResponseSenderBlock)callback)
445
470
{
446
471
if (self.delegate != nil ) {
447
472
NSMutableArray <NSString *> *keys = [NSMutableArray arrayWithCapacity: kvPairs.count];
@@ -575,3 +600,4 @@ - (BOOL)_passthroughDelegate
575
600
}
576
601
577
602
@end
603
+
0 commit comments