mirror of
https://github.com/tappollo/WWDC.git
synced 2026-04-29 04:15:12 +08:00
Showing spinner on first load
This commit is contained in:
@@ -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 }
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user