From 6023306f86c0b4fc0bca8941ad90a7008db36323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mro=CC=81z?= Date: Sat, 23 Jan 2021 16:26:23 +0100 Subject: [PATCH] Small fixes to upload button at the end of a session --- Tree Tracker/Screens/UploadList/UploadListViewModel.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Tree Tracker/Screens/UploadList/UploadListViewModel.swift b/Tree Tracker/Screens/UploadList/UploadListViewModel.swift index a76fa93..a6c6864 100644 --- a/Tree Tracker/Screens/UploadList/UploadListViewModel.swift +++ b/Tree Tracker/Screens/UploadList/UploadListViewModel.swift @@ -9,7 +9,6 @@ protocol UploadListNavigating: AnyObject { final class UploadListViewModel { @Published var title: String @Published var data: [ListSection] - @Published var syncProgress: SyncProgress? @Published var syncButton: ButtonModel? @Published var navigationButtons: [NavigationBarButtonModel] @@ -64,12 +63,17 @@ final class UploadListViewModel { private func stopUploading() { print("Uploading cancelled.") currentUpload?.cancel() + presentTreesFromDatabase() } private func uploadLocalTreesRecursively() { print("Uploading images...") database.fetchLocalTrees { [weak self] trees in - guard let tree = trees.first else { return } + guard let tree = trees.first else { + print("No more items to upload - bailing.") + self?.presentUploadButton(isUploading: false) + return + } print("Now uploading tree: \(tree)") self?.currentUpload = self?.api.upload(