-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserTimeZoneSyncHandler.swift
More file actions
35 lines (31 loc) · 1.01 KB
/
UserTimeZoneSyncHandler.swift
File metadata and controls
35 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// UserTimeZoneSyncHandler.swift
// DevLog
//
// Created by opfic on 3/19/26.
//
import Combine
import UIKit
final class UserTimeZoneSyncHandler {
private let repository: UserDataRepository
private let logger = Logger(category: "UserTimeZoneSyncHandler")
private var cancellables = Set<AnyCancellable>()
init(
repository: UserDataRepository,
notificationCenter: NotificationCenter = .default
) {
self.repository = repository
notificationCenter.publisher(for: .didRequestUserTimeZoneSync)
.merge(with: notificationCenter.publisher(for: UIApplication.willEnterForegroundNotification))
.sink { [weak self] _ in
Task {
do {
try await self?.repository.updateUserTimeZone()
} catch {
self?.logger.error("Failed to sync user timeZone", error: error)
}
}
}
.store(in: &cancellables)
}
}