Skip to content
This repository was archived by the owner on Jun 19, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Jeff/JEFDropboxRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//

#import "JEFRecordingsRepository.h"
#import "JEFRecordingsProvider.h"
#import "JEFSyncingService.h"

@class JEFRecording;
Expand Down
17 changes: 11 additions & 6 deletions Jeff/JEFDropboxRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,25 @@ - (void)removeRecording:(JEFRecording *)recording {
[self.openRecordingPaths removeObject:recording.path.stringValue];
}

- (void)loadRecordings {
DBFilesystem *sharedFilesystem = [DBFilesystem sharedFilesystem];
BOOL isShutdown = sharedFilesystem.isShutDown;
BOOL notFinishedSyncing = !sharedFilesystem.completedFirstSync;
- (void)loadRecordings:(DBFilesystem *)filesystem {
BOOL isShutdown = filesystem.isShutDown;
BOOL notFinishedSyncing = !filesystem.completedFirstSync;
if (isShutdown || notFinishedSyncing) return;

DBError *listError;
NSArray *files = [sharedFilesystem listFolder:[DBPath root] error:&listError];
NSArray *files = [filesystem listFolder:[DBPath root] error:&listError];
if (listError) {
RBKLog(@"Error listing files: %@", listError);
return;
}
for (DBFileInfo *fileInfo in files) {
// Skip files with trivially invalid paths
if (RBKIsEmpty(fileInfo.path.stringValue)) continue;
// Skip non-GIFs
if ([[[NSURL alloc] initFileURLWithPath:fileInfo.path.stringValue].pathExtension caseInsensitiveCompare:@"gif"] != NSOrderedSame) continue;
// Skip GIFs that are already open
if ([self.openRecordingPaths containsObject:fileInfo.path.stringValue]) continue;

JEFRecording *newRecording = [JEFRecording recordingWithFileInfo:fileInfo];
if (newRecording) {
[self addRecording:newRecording];
Expand All @@ -94,7 +99,7 @@ - (void)setupDropboxFilesystem {

__weak __typeof(self) weakSelf = self;
[[DBFilesystem sharedFilesystem] addObserver:self block:^{
[weakSelf loadRecordings];
[weakSelf loadRecordings:[DBFilesystem sharedFilesystem]];

BOOL stateIsSyncing = [DBFilesystem sharedFilesystem].status.download.inProgress;
BOOL hasRecordings = weakSelf.recordings.count > 0;
Expand Down