Skip to content

Commit

Permalink
fix(storage): set emulator once for each bucket it is required
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Nov 13, 2023
1 parent 7c4180a commit 4860783
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ @interface FLTFirebaseStoragePlugin ()
@implementation FLTFirebaseStoragePlugin {
NSMutableDictionary<NSNumber *, FIRStorageObservableTask<FIRStorageTaskManagement> *> *_tasks;
dispatch_queue_t _callbackQueue;
bool hasEmulatorBooted;
NSMutableDictionary<NSString *, NSNumber *> *_emulatorBooted;
NSObject<FlutterBinaryMessenger> *_binaryMessenger;
NSMutableDictionary<NSString *, FlutterEventChannel *> *_eventChannels;
NSMutableDictionary<NSString *, NSObject<FlutterStreamHandler> *> *_streamHandlers;
Expand Down Expand Up @@ -97,7 +97,7 @@ - (instancetype)init:(NSObject<FlutterBinaryMessenger> *)messenger {
dictionary];
_callbackQueue =
dispatch_queue_create("io.flutter.plugins.firebase.storage", DISPATCH_QUEUE_SERIAL);
hasEmulatorBooted = false;
_emulatorBooted = [[NSMutableDictionary alloc] init];
_binaryMessenger = messenger;
_eventChannels = [NSMutableDictionary dictionary];
_streamHandlers = [NSMutableDictionary dictionary];
Expand Down Expand Up @@ -242,9 +242,11 @@ - (void)useStorageEmulatorApp:(PigeonStorageFirebaseApp *)app
port:(NSNumber *)port
completion:(void (^)(FlutterError *_Nullable))completion {
FIRStorage *storage = [self getFIRStorageFromAppNameFromPigeon:app];
if (hasEmulatorBooted == false) {
NSNumber *emulatorKey = _emulatorBooted[app.bucket];

if (emulatorKey == nil) {
[storage useEmulatorWithHost:host port:[port integerValue]];
hasEmulatorBooted = true;
[_emulatorBooted setObject:@(YES) forKey:app.bucket];
}
completion(nil);
}
Expand Down

0 comments on commit 4860783

Please sign in to comment.