Skip to content

Commit 1299e4b

Browse files
authored
[#408] 로그아웃, 회원탈퇴 후 위젯에 데이터가 유지되는 현상을 해결한다 (#409)
* chore: l10n 진행 * chore: Xcode 지역화 설정 갱신 * ui: 'Heatmap' 제거 * ui: 요일 라벨 제거 * refactor: key 형태로 하드코딩 요소 대체 * feat: 삭제 키 추가 * fix: 위젯 스냅샷 삭제 로직 추가 * fix: 로그아웃 및 회원탈퇴 시 위젯 데이터 제거 * refactor: key 형태로 하드코딩 요소 대체 * feat: 삭제 키 추가 * fix: 위젯 스냅샷 삭제 로직 추가 * fix: 로그아웃 및 회원탈퇴 시 위젯 데이터 제거 * fix: 사용자별 Preference가 지워지지 않는 현상 해결 * fix: 위젯 사용자 설정 초기화 로직 추가 * chore: 마케팅 버전 1.1.0으로 버전업
1 parent 405ee73 commit 1299e4b

15 files changed

Lines changed: 136 additions & 31 deletions

DevLog.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
DEVELOPMENT_TEAM = 4CPC6N38WA;
397397
GENERATE_INFOPLIST_FILE = YES;
398398
IPHONEOS_DEPLOYMENT_TARGET = 17;
399-
MARKETING_VERSION = 1.0.1;
399+
MARKETING_VERSION = 1.1.0;
400400
PRODUCT_BUNDLE_IDENTIFIER = opfic.DevLog_Unit;
401401
PRODUCT_NAME = "$(TARGET_NAME)";
402402
STRING_CATALOG_GENERATE_SYMBOLS = NO;
@@ -421,7 +421,7 @@
421421
DEVELOPMENT_TEAM = 4CPC6N38WA;
422422
GENERATE_INFOPLIST_FILE = YES;
423423
IPHONEOS_DEPLOYMENT_TARGET = 17;
424-
MARKETING_VERSION = 1.0.1;
424+
MARKETING_VERSION = 1.1.0;
425425
PRODUCT_BUNDLE_IDENTIFIER = opfic.DevLog_Unit;
426426
PRODUCT_NAME = "$(TARGET_NAME)";
427427
STRING_CATALOG_GENERATE_SYMBOLS = NO;
@@ -457,7 +457,7 @@
457457
"@executable_path/Frameworks",
458458
"@executable_path/../../Frameworks",
459459
);
460-
MARKETING_VERSION = 1.0.1;
460+
MARKETING_VERSION = 1.1.0;
461461
PRODUCT_BUNDLE_IDENTIFIER = opfic.DevLog.DevLogWidget;
462462
PRODUCT_NAME = "$(TARGET_NAME)";
463463
SKIP_INSTALL = YES;
@@ -490,7 +490,7 @@
490490
"@executable_path/Frameworks",
491491
"@executable_path/../../Frameworks",
492492
);
493-
MARKETING_VERSION = 1.0.1;
493+
MARKETING_VERSION = 1.1.0;
494494
PRODUCT_BUNDLE_IDENTIFIER = opfic.DevLog.DevLogWidget;
495495
PRODUCT_NAME = "$(TARGET_NAME)";
496496
SKIP_INSTALL = YES;
@@ -536,7 +536,7 @@
536536
"@executable_path/Frameworks",
537537
);
538538
LOCALIZED_STRING_SWIFTUI_SUPPORT = YES;
539-
MARKETING_VERSION = 1.0.1;
539+
MARKETING_VERSION = 1.1.0;
540540
PRODUCT_BUNDLE_IDENTIFIER = opfic.DevLog;
541541
PRODUCT_NAME = "$(TARGET_NAME)";
542542
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -583,7 +583,7 @@
583583
"@executable_path/Frameworks",
584584
);
585585
LOCALIZED_STRING_SWIFTUI_SUPPORT = YES;
586-
MARKETING_VERSION = 1.0.1;
586+
MARKETING_VERSION = 1.1.0;
587587
PRODUCT_BUNDLE_IDENTIFIER = opfic.DevLog;
588588
PRODUCT_NAME = "$(TARGET_NAME)";
589589
PROVISIONING_PROFILE_SPECIFIER = "";

DevLog/App/Assembler/DataAssembler.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ final class DataAssembler: Assembler {
2222
AuthenticationService.self,
2323
name: "GoogleAuthenticationService"
2424
),
25-
userService: container.resolve(UserService.self)
25+
userService: container.resolve(UserService.self),
26+
widgetSnapshotUpdater: container.resolve(WidgetSnapshotUpdater.self)
2627
)
2728
}
2829

DevLog/Data/Repository/AuthenticationRepositoryImpl.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ final class AuthenticationRepositoryImpl: AuthenticationRepository {
1111
private let githubAuthService: AuthenticationService
1212
private let googleAuthService: AuthenticationService
1313
private let userService: UserService
14+
private let widgetSnapshotUpdater: WidgetSnapshotUpdater
1415

1516
init(
1617
authService: AuthService,
1718
appleAuthService: AuthenticationService,
1819
githubAuthService: AuthenticationService,
1920
googleAuthService: AuthenticationService,
20-
userService: UserService
21+
userService: UserService,
22+
widgetSnapshotUpdater: WidgetSnapshotUpdater
2123
) {
2224
self.authService = authService
2325
self.appleAuthService = appleAuthService
2426
self.githubAuthService = githubAuthService
2527
self.googleAuthService = googleAuthService
2628
self.userService = userService
29+
self.widgetSnapshotUpdater = widgetSnapshotUpdater
2730
}
2831

2932
func signIn(_ provider: AuthProvider) async throws {
@@ -58,6 +61,7 @@ final class AuthenticationRepositoryImpl: AuthenticationRepository {
5861
let provider = AuthProvider(rawValue: providerID)
5962
else {
6063
try await authService.clearCurrentSession()
64+
widgetSnapshotUpdater.clear()
6165
return
6266
}
6367

@@ -73,6 +77,8 @@ final class AuthenticationRepositoryImpl: AuthenticationRepository {
7377
} catch AuthError.notAuthenticated {
7478
try await authService.clearCurrentSession()
7579
}
80+
81+
widgetSnapshotUpdater.clear()
7682
}
7783

7884
func restore() -> Bool {
@@ -100,5 +106,6 @@ final class AuthenticationRepositoryImpl: AuthenticationRepository {
100106

101107
try await authService.deleteCurrentUser()
102108
try await authService.clearCurrentSession()
109+
widgetSnapshotUpdater.clear()
103110
}
104111
}

DevLog/Storage/Persistence/WidgetSnapshotPreferenceStore.swift

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import Foundation
99

1010
final class WidgetSnapshotPreferenceStore {
11-
private enum Key {
12-
static let heatmapActivityTypes = "Profile.heatmap.activityTypes"
13-
static let todayDueDateVisibility = "Today.dueDateVisibility"
14-
static let todayFocusVisibility = "Today.focusVisibility"
11+
private enum Key: String, CaseIterable {
12+
case heatmapActivityTypes = "Profile.heatmap.activityTypes"
13+
case todayDueDateVisibility = "Today.dueDateVisibility"
14+
case todayFocusVisibility = "Today.focusVisibility"
1515
}
1616

1717
private let userDefaults: UserDefaults
@@ -21,11 +21,11 @@ final class WidgetSnapshotPreferenceStore {
2121
}
2222

2323
func heatmapActivityTypes() -> [String] {
24-
userDefaults.stringArray(forKey: Key.heatmapActivityTypes) ?? []
24+
userDefaults.stringArray(forKey: Key.heatmapActivityTypes.rawValue) ?? []
2525
}
2626

2727
func setHeatmapActivityTypes(_ activityTypes: [String]) {
28-
userDefaults.set(activityTypes, forKey: Key.heatmapActivityTypes)
28+
userDefaults.set(activityTypes, forKey: Key.heatmapActivityTypes.rawValue)
2929
}
3030

3131
func selectedActivityKinds() -> Set<ActivityKind> {
@@ -41,8 +41,8 @@ final class WidgetSnapshotPreferenceStore {
4141
}
4242

4343
func todayDisplayOptions() -> TodayDisplayOptions {
44-
let dueDateVisibilityRawValue = userDefaults.string(forKey: Key.todayDueDateVisibility)
45-
let focusVisibilityRawValue = userDefaults.string(forKey: Key.todayFocusVisibility)
44+
let dueDateVisibilityRawValue = userDefaults.string(forKey: Key.todayDueDateVisibility.rawValue)
45+
let focusVisibilityRawValue = userDefaults.string(forKey: Key.todayFocusVisibility.rawValue)
4646

4747
return TodayDisplayOptions(
4848
dueDateVisibility: TodayDisplayOptions.DueDateVisibility(
@@ -55,7 +55,13 @@ final class WidgetSnapshotPreferenceStore {
5555
}
5656

5757
func setTodayDisplayOptions(_ options: TodayDisplayOptions) {
58-
userDefaults.set(options.dueDateVisibility.rawValue, forKey: Key.todayDueDateVisibility)
59-
userDefaults.set(options.focusVisibility.rawValue, forKey: Key.todayFocusVisibility)
58+
userDefaults.set(options.dueDateVisibility.rawValue, forKey: Key.todayDueDateVisibility.rawValue)
59+
userDefaults.set(options.focusVisibility.rawValue, forKey: Key.todayFocusVisibility.rawValue)
60+
}
61+
62+
func clear() {
63+
Key.allCases.forEach {
64+
userDefaults.removeObject(forKey: $0.rawValue)
65+
}
6066
}
6167
}

DevLog/Storage/Persistence/WidgetSnapshotUpdater.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,10 @@ final class WidgetSnapshotUpdater {
104104
)
105105
}
106106
}
107+
108+
func clear() {
109+
snapshotStore.clearSnapshots()
110+
preferenceStore.clear()
111+
WidgetCenter.shared.reloadAllTimelines()
112+
}
107113
}

DevLog/Widget/Common/WidgetSharedDefaultsStore.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ final class WidgetSharedDefaultsStore {
2121
func setData(_ value: Data?, forKey key: String) {
2222
userDefaults.set(value, forKey: key)
2323
}
24+
25+
func removeObject(forKey key: String) {
26+
userDefaults.removeObject(forKey: key)
27+
}
2428
}

DevLog/Widget/Common/WidgetSnapshotStore.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ final class WidgetSnapshotStore {
3535
guard let data = store.data(forKey: WidgetSnapshotKey.heatmap) else { return nil }
3636
return try decoder.decode(HeatmapWidgetSnapshot.self, from: data)
3737
}
38+
39+
func clearSnapshots() {
40+
WidgetSnapshotKey.snapshots.forEach {
41+
store.removeObject(forKey: $0)
42+
}
43+
}
3844
}

DevLogWidget/Heatmap/HeatmapWidget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct HeatmapWidget: Widget {
2222
.containerBackground(.fill.tertiary, for: .widget)
2323
.widgetURL(WidgetDeepLink.heatmapURL)
2424
}
25-
.configurationDisplayName("Heatmap")
25+
.configurationDisplayName(LocalizedStringResource("widget_heatmap_title"))
2626
.description("widget_heatmap_description")
2727
.supportedFamilies([.systemSmall, .systemMedium])
2828
}

DevLogWidget/Heatmap/HeatmapWidgetConfigurationIntent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ import AppIntents
99
import WidgetKit
1010

1111
struct HeatmapWidgetConfigurationIntent: WidgetConfigurationIntent {
12-
static var title: LocalizedStringResource = "Heatmap"
12+
static var title: LocalizedStringResource = "widget_heatmap_title"
1313
static var description = IntentDescription("widget_heatmap_description")
1414
}

DevLogWidget/Resource/Localizable.xcstrings

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
},
77
"%lld" : {
88

9-
},
10-
"Heatmap" : {
11-
12-
},
13-
"Today" : {
14-
159
},
1610
"widget_heatmap_current_month_title" : {
1711
"extractionState" : "manual",
@@ -64,6 +58,23 @@
6458
}
6559
}
6660
},
61+
"widget_heatmap_title" : {
62+
"extractionState" : "manual",
63+
"localizations" : {
64+
"en" : {
65+
"stringUnit" : {
66+
"state" : "translated",
67+
"value" : "Heatmap"
68+
}
69+
},
70+
"ko" : {
71+
"stringUnit" : {
72+
"state" : "translated",
73+
"value" : "Heatmap"
74+
}
75+
}
76+
}
77+
},
6778
"widget_today_description" : {
6879
"extractionState" : "manual",
6980
"localizations" : {
@@ -97,6 +108,23 @@
97108
}
98109
}
99110
}
111+
},
112+
"widget_today_title" : {
113+
"extractionState" : "manual",
114+
"localizations" : {
115+
"en" : {
116+
"stringUnit" : {
117+
"state" : "translated",
118+
"value" : "Today"
119+
}
120+
},
121+
"ko" : {
122+
"stringUnit" : {
123+
"state" : "translated",
124+
"value" : "Today"
125+
}
126+
}
127+
}
100128
}
101129
},
102130
"version" : "1.0"

0 commit comments

Comments
 (0)