Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
update at day change, close #16
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerwooo committed Aug 11, 2022
1 parent 54bc867 commit d0536b7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions PaimonMenuBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 121;
CURRENT_PROJECT_VERSION = 122;
DEVELOPMENT_ASSET_PATHS = "\"PaimonMenuBar/Preview Content\"";
DEVELOPMENT_TEAM = W2HGAU9MPP;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -397,7 +397,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 121;
CURRENT_PROJECT_VERSION = 122;
DEVELOPMENT_ASSET_PATHS = "\"PaimonMenuBar/Preview Content\"";
DEVELOPMENT_TEAM = W2HGAU9MPP;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
12 changes: 12 additions & 0 deletions PaimonMenuBar/GameRecordUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ class GameRecordUpdater {
}
}

// MARK: - Record update at midnight to avoid today or tomorrow conflicts

This comment has been minimized.

Copy link
@spencerwooo

spencerwooo Aug 11, 2022

Author Owner

@ArvinZJC dunno if this would work as expected -- 有时间观察一下呗


private func setupDayChangeUpdater() {
assert(Thread.isMainThread)

NotificationCenter.default.addObserver(forName: .NSCalendarDayChanged, object: nil, queue: .main) { _ in
print("Day change (midnight) update is triggered")
self.tryFetchGameRecordAndRender()
}
}

// MARK: - Notification handler

private func sendLocalNotification(context: LocalizedStringKey, completion: @escaping () -> Void) {
Expand Down Expand Up @@ -132,6 +143,7 @@ class GameRecordUpdater {
init() {
startNetworkActivityUpdater()
resetUpdateTimer()
setupDayChangeUpdater()

Defaults.observe(.recordUpdateInterval) { _ in
self.onRecordUpdateIntervalChanged()
Expand Down
2 changes: 1 addition & 1 deletion PaimonMenuBar/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct ConfigurationSettingsView: View {

var body: some View {
VStack {
Text("Personal information")
Text("User")
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
Form {
Expand Down
4 changes: 2 additions & 2 deletions PaimonMenuBar/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

"Paste your cookie from:" = "从这里粘贴你的 Cookie:";

"Personal information" = "个人信息";
"User" = "个人信息";

"Preferences" = "偏好设置";

Expand Down Expand Up @@ -112,4 +112,4 @@

"⚠️ Notification unauthorized." = "⚠️ 没有推送通知权限。";

"This cookie is only stored locally." = "Cookie 仅保存于本地";
"This cookie is only stored locally." = "Cookie 仅保存于本地";

0 comments on commit d0536b7

Please sign in to comment.