From c1308291df5ac65574d7df725afcb83b7b3f0f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Junnos=20=EF=A3=BF?= Date: Mon, 11 Dec 2023 04:15:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:bug:=20=EC=97=AC=EC=A0=95=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=ED=9B=84=20=ED=99=88=EC=9C=BC=EB=A1=9C=20=EB=8F=8C?= =?UTF-8?q?=EC=95=84=EA=B0=80=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Sources/Home/Presentation/HomeViewModel.swift | 8 ++++---- .../SaveJourney/Presentation/SaveJourneyViewModel.swift | 1 + .../FileManager/FileManagerStorage.swift | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift b/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift index d70982f..1156fbe 100644 --- a/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift +++ b/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift @@ -67,10 +67,10 @@ public final class HomeViewModel { func trigger(_ action: Action) { switch action { case .viewNeedsLoaded: - #if DEBUG - self.isFirstLaunch = true - try? self.keychain.deleteAll() - #endif +// #if DEBUG +// self.isFirstLaunch = true +// try? self.keychain.deleteAll() +// #endif let firstLaunchMessage = self.isFirstLaunch ? "앱이 처음 실행되었습니다." : "앱 첫 실행이 아닙니다." MSLogger.make(category: .userDefaults).log("\(firstLaunchMessage)") diff --git a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewModel.swift b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewModel.swift index 437a2d5..e6b21c2 100644 --- a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewModel.swift +++ b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/SaveJourneyViewModel.swift @@ -111,6 +111,7 @@ private extension SaveJourneyViewModel { #if DEBUG MSLogger.make(category: .saveJourney).log("\(journeyID)가 저장되었습니다.") #endif + self.state.endJourneySucceed.send(journey) case .failure(let error): MSLogger.make(category: .saveJourney).error("\(error)") } diff --git a/iOS/MSCoreKit/Sources/MSPersistentStorage/FileManager/FileManagerStorage.swift b/iOS/MSCoreKit/Sources/MSPersistentStorage/FileManager/FileManagerStorage.swift index 63165fb..4c54136 100644 --- a/iOS/MSCoreKit/Sources/MSPersistentStorage/FileManager/FileManagerStorage.swift +++ b/iOS/MSCoreKit/Sources/MSPersistentStorage/FileManager/FileManagerStorage.swift @@ -146,15 +146,15 @@ extension FileManagerStorage { func storageURL(create: Bool = false) -> URL? { let directoryURL: URL? if #available(iOS 16.0, *) { - let storageDirectoryURL = try? self.fileManager.url(for: .applicationDirectory, + let storageDirectoryURL = try? self.fileManager.url(for: .cachesDirectory, in: .userDomainMask, - appropriateFor: .applicationDirectory, + appropriateFor: .cachesDirectory, create: false) directoryURL = storageDirectoryURL? .appending(path: Constants.appBundleIdentifier, directoryHint: .isDirectory) } else { let cacheDirectoryURL = self.fileManager - .urls(for: .applicationDirectory, in: .userDomainMask) + .urls(for: .cachesDirectory, in: .userDomainMask) .first directoryURL = cacheDirectoryURL? .appendingPathComponent(Constants.appBundleIdentifier, isDirectory: true) From a645a673255aa07033f790d1d850e569431f98b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Junnos=20=EF=A3=BF?= Date: Mon, 11 Dec 2023 04:41:37 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:bug:=20=EC=97=AC=EC=A0=95=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=ED=9B=84=20=ED=99=88=EC=9C=BC=EB=A1=9C=20=EB=8F=8C?= =?UTF-8?q?=EC=95=84=EA=B0=80=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=98=84?= =?UTF-8?q?=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Presentation/HomeViewController.swift | 6 ++++++ .../Home/Presentation/HomeViewModel.swift | 4 ++++ .../MSData/Repository/JourneyRepository.swift | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/iOS/Features/Home/Sources/Home/Presentation/HomeViewController.swift b/iOS/Features/Home/Sources/Home/Presentation/HomeViewController.swift index ac0183a..7420dcd 100644 --- a/iOS/Features/Home/Sources/Home/Presentation/HomeViewController.swift +++ b/iOS/Features/Home/Sources/Home/Presentation/HomeViewController.swift @@ -116,6 +116,12 @@ public final class HomeViewController: HomeBottomSheetViewController { self.navigationController?.isNavigationBarHidden = true } + public override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + self.viewModel.trigger(.viewNeedsReloaded) + } + // MARK: - Combine Binding private func bind() { diff --git a/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift b/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift index 1156fbe..559795b 100644 --- a/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift +++ b/iOS/Features/Home/Sources/Home/Presentation/HomeViewModel.swift @@ -22,6 +22,7 @@ public final class HomeViewModel { public enum Action { case viewNeedsLoaded + case viewNeedsReloaded case startButtonDidTap(Coordinate) case refreshButtonDidTap(visibleCoordinates: (minCoordinate: Coordinate, maxCoordinate: Coordinate)) case backButtonDidTap @@ -77,6 +78,9 @@ public final class HomeViewModel { if self.isFirstLaunch { self.createNewUser() } + case .viewNeedsReloaded: + let isRecording = self.journeyRepository.fetchIsRecording() + self.state.isRecording.send(isRecording) case .startButtonDidTap(let coordinate): #if DEBUG MSLogger.make(category: .home).debug("Start 버튼 탭: \(coordinate)") diff --git a/iOS/MSData/Sources/MSData/Repository/JourneyRepository.swift b/iOS/MSData/Sources/MSData/Repository/JourneyRepository.swift index cc4003e..9d9d604 100644 --- a/iOS/MSData/Sources/MSData/Repository/JourneyRepository.swift +++ b/iOS/MSData/Sources/MSData/Repository/JourneyRepository.swift @@ -17,6 +17,8 @@ import MSUserDefaults public protocol JourneyRepository: Persistable { + func fetchIsRecording() -> Bool + mutating func updateIsRecording(_ isRecording: Bool) -> Bool func fetchRecordingJourneyID() -> String? func fetchRecordingJourney(forID id: String) -> RecordingJourney? func fetchJourneyList(userID: UUID, @@ -36,6 +38,9 @@ public struct JourneyRepositoryImplementation: JourneyRepository { private let networking: MSNetworking public let storage: MSPersistentStorage + @UserDefaultsWrapped(UserDefaultsKey.isRecording, defaultValue: false) + private var isRecording: Bool + @UserDefaultsWrapped(UserDefaultsKey.recordingJourneyID, defaultValue: nil) private var recordingJourneyID: String? @@ -49,6 +54,16 @@ public struct JourneyRepositoryImplementation: JourneyRepository { // MARK: - Functions + public func fetchIsRecording() -> Bool { + return self.isRecording + } + + @discardableResult + public mutating func updateIsRecording(_ isRecording: Bool) -> Bool { + self.isRecording = isRecording + return self.isRecording + } + public func fetchRecordingJourneyID() -> String? { guard let recordingJourneyID = self.recordingJourneyID else { MSLogger.make(category: .userDefaults).error("기록 중인 여정 정보를 가져오는데 실패했습니다.") @@ -118,6 +133,7 @@ public struct JourneyRepositoryImplementation: JourneyRepository { self.saveToLocal(value: recordingJourney.id) self.saveToLocal(value: recordingJourney.startTimestamp) + self.isRecording = true self.recordingJourneyID = recordingJourney.id #if DEBUG @@ -168,6 +184,7 @@ public struct JourneyRepositoryImplementation: JourneyRepository { switch result { case .success(let responseDTO): self.recordingJourneyID = nil + self.isRecording = false return .success(responseDTO.id) case .failure(let error): return .failure(error) @@ -182,6 +199,7 @@ public struct JourneyRepositoryImplementation: JourneyRepository { switch result { case .success(let responseDTO): self.recordingJourneyID = nil + self.isRecording = false return .success(responseDTO.id) case .failure(let error): return .failure(error) From 57504e0bda6a5696de87ddae80a55e3dc0acc56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Junnos=20=EF=A3=BF?= Date: Mon, 11 Dec 2023 04:44:12 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:bug:=20lowerbound=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/MSUIKit/Sources/MSUIKit/Cells/JourneyCell/JourneyCell.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iOS/MSUIKit/Sources/MSUIKit/Cells/JourneyCell/JourneyCell.swift b/iOS/MSUIKit/Sources/MSUIKit/Cells/JourneyCell/JourneyCell.swift index d95b160..4b5b148 100644 --- a/iOS/MSUIKit/Sources/MSUIKit/Cells/JourneyCell/JourneyCell.swift +++ b/iOS/MSUIKit/Sources/MSUIKit/Cells/JourneyCell/JourneyCell.swift @@ -80,6 +80,8 @@ public final class JourneyCell: UICollectionViewCell { @MainActor public func addImageView(count: Int) { + guard count != .zero else { return } + (1...count).forEach { _ in let imageView = SpotPhotoImageView() self.spotImageStack.addArrangedSubview(imageView)