Skip to content

Commit

Permalink
fix timer (#92)
Browse files Browse the repository at this point in the history
* fix timer

* chore

* change version
  • Loading branch information
donggyushin authored Aug 13, 2024
1 parent 4ce8f5d commit 2dc0657
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 37 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ on:
branches: ["main", "staging"]

jobs:
list-macos-versions:
runs-on: ubuntu-latest
steps:
- name: Check available macOS versions
run: |
echo "Available macOS versions:"
curl -s https://api.github.com/meta | jq -r '.runner | .macos'
build:
name: Build and Test default scheme using any available iPhone simulator
runs-on: macos-14
Expand Down
2 changes: 1 addition & 1 deletion Derived/InfoPlists/DgWidget-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>2.11.0</string>
<string>2.10.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
Expand Down
2 changes: 1 addition & 1 deletion Derived/InfoPlists/app-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.11.0</string>
<string>2.10.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down
2 changes: 1 addition & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ProjectDescription
let projectName = "dg-muscle-ios"
let widgetName = "DgWidget"
let bundleId = "com.donggyu.dg-muscle-ios"
let appVersion: String = "2.11.0"
let appVersion: String = "2.10.0"

enum Layer: String, CaseIterable {
case Domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class ManageRecordViewModel: ObservableObject {
@Published var goal: Goal?
@Published var strengthGoal: Goal?
@Published var traingMode: Common.TrainingMode?
@Published var lastSelectedTime: Int?

private let recordId: String
private let getHeatMapColorUsecase: GetHeatMapColorUsecase
Expand All @@ -32,7 +31,6 @@ final class ManageRecordViewModel: ObservableObject {
private let subscribeTrainingModeUsecase: SubscribeTrainingModeUsecase
private let checkGoalAchievedUsecase: CheckGoalAchievedUsecase
private let checkStrengthGoalAchievedUsecase: CheckStrengthGoalAchievedUsecase
private let cancelExerciseTimerUsecase: CancelExerciseTimerUsecase
private let registerExerciseTimerUsecase: RegisterExerciseTimerUsecase
private var cancellables = Set<AnyCancellable>()

Expand Down Expand Up @@ -62,7 +60,6 @@ final class ManageRecordViewModel: ObservableObject {
subscribeTrainingModeUsecase = .init(userRepository: userRepository)
checkGoalAchievedUsecase = .init()
checkStrengthGoalAchievedUsecase = .init()
cancelExerciseTimerUsecase = .init(exerciseTimerRepository: exerciseTimerRepository)
registerExerciseTimerUsecase = .init(exerciseTimerRepository: exerciseTimerRepository)

let color: Common.HeatMapColor = .init(domain: getHeatMapColorUsecase.implement())
Expand All @@ -85,32 +82,25 @@ final class ManageRecordViewModel: ObservableObject {
Common.PushNotificationManager.shared.delete(ids: ["ExerciseTimer\(i)"])
}

if lastSelectedTime == time {
cancelExerciseTimerUsecase.implement()
lastSelectedTime = nil
} else {
if var date = Calendar.current.date(byAdding: .second, value: time, to: Date()) {
registerExerciseTimerUsecase.implement(timer: .init(targetDate: date))
if var date = Calendar.current.date(byAdding: .second, value: time, to: Date()) {
registerExerciseTimerUsecase.implement(timer: .init(targetDate: date))

for i in (0..<10) {
Common.PushNotificationManager.shared.register(
title: "Ring Ring Ring...",
body: "Tap to stop alarm",
date: date,
id: "ExerciseTimer\(i)",
userInfo: [
"type": "timer",
"targetDate": date
]
)

for i in (0..<10) {
Common.PushNotificationManager.shared.register(
title: "Ring Ring Ring...",
body: "Tap to stop alarm",
date: date,
id: "ExerciseTimer\(i)",
userInfo: [
"type": "timer",
"targetDate": date
]
)

if let updatedDate = Calendar.current.date(byAdding: .second, value: 3, to: date) {
date = updatedDate
}
if let updatedDate = Calendar.current.date(byAdding: .second, value: 3, to: date) {
date = updatedDate
}
}

lastSelectedTime = time
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation
import Domain
import Combine
import ExerciseTimer
import Common

final class NavigationViewModel: ObservableObject {
let subscribeExerciseTimerUsecase: SubscribeExerciseTimerUsecase
Expand All @@ -25,6 +26,9 @@ final class NavigationViewModel: ObservableObject {

func cancelTimer() {
cancelExerciseTimerUsecase.implement()
for i in (0..<10) {
Common.PushNotificationManager.shared.delete(ids: ["ExerciseTimer\(i)"])
}
}

private func bind() {
Expand Down

0 comments on commit 2dc0657

Please sign in to comment.