Showing spinner on first load

This commit is contained in:
Guilherme Rambo
2017-05-21 17:52:16 -03:00
parent f8d195dc32
commit 7212f78085
3 changed files with 22 additions and 0 deletions

View File

@@ -302,6 +302,10 @@ public final class Storage {
}
}
public var isEmpty: Bool {
return realm.objects(Event.self).count <= 0
}
public func removeFavorite(for session: Session) {
guard let favorite = session.favorites.first else { return }

View File

@@ -182,6 +182,10 @@ final class AppCoordinator {
}
private func doUpdateLists() {
if !storage.isEmpty {
tabController.hideLoading()
}
storage.tracksObservable.subscribe(onNext: { [weak self] tracks in
self?.videosController.listViewController.tracks = tracks
}).dispose()
@@ -204,6 +208,10 @@ final class AppCoordinator {
windowController.contentViewController = tabController
windowController.showWindow(self)
if storage.isEmpty {
tabController.showLoading()
}
NotificationCenter.default.addObserver(forName: .SyncEngineDidSyncSessionsAndSchedule, object: nil, queue: OperationQueue.main) { _ in
self.updateListsAfterSync(migrate: true)
}

View File

@@ -145,4 +145,14 @@ class WWDCTabViewController<Tab: RawRepresentable>: NSTabViewController where Ta
return self.view.window?.toolbar?.items.flatMap({ $0.view as? TabItemView }) ?? []
}
private var loadingView: ModalLoadingView?
func showLoading() {
loadingView = ModalLoadingView.show(attachedTo: self.view)
}
func hideLoading() {
loadingView?.hide()
}
}