-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: latest timestamp get status #105
Conversation
WalkthroughThe Changes
Sequence DiagramsequenceDiagram
participant User
participant BitcoinView
participant ViewModel
User->>BitcoinView: Access BitcoinView
BitcoinView->>ViewModel: Fetch status and latestOnchainWalletSyncTimestamp
alt Both data available
ViewModel-->>BitcoinView: Provide status and timestamp
BitcoinView->>BitcoinView: Format and display date
else Any data missing
ViewModel-->>BitcoinView: Provide available data
BitcoinView->>BitcoinView: Skip date formatting
end
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- LDKNodeMonday/View/Home/BitcoinView.swift (2 hunks)
Additional context used
SwiftLint
LDKNodeMonday/View/Home/BitcoinView.swift
[Warning] 231-231: Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
[Warning] 231-231: Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
Additional comments not posted (2)
LDKNodeMonday/View/Home/BitcoinView.swift (2)
62-76
: Ensure Timezone Handling in Date FormattingThe new logic for date formatting correctly checks if both
viewModel.status
andlatestOnchainWalletSyncTimestamp
are available before formatting the date. However, the code does not specify a timezone for the date conversion which may lead to incorrect display times depending on the user's locale.Consider specifying a timezone or ensuring the UI communicates the timezone used for clarity.
let date = Date(timeIntervalSince1970: TimeInterval(timestamp)) // Suggest using a specific timezone or UTC let dateFormatter = DateFormatter() dateFormatter.timeZone = TimeZone(abbreviation: "UTC") // or any other specific timezone let formattedDate = dateFormatter.string(from: date) Text(formattedDate)
104-118
: Duplicate Code for Date FormattingThe conditional logic for date formatting is duplicated in the file. This occurs twice for different sections of the view. To improve maintainability, consider refactoring this logic into a separate method or view component that can be reused.
This will make the code cleaner and easier to maintain, especially if changes are needed in the future.
[REFACTOR_SUGGESTion]// Suggested refactoring into a method extension BitcoinView { func formattedDateText(timestamp: Int) -> some View { let date = Date(timeIntervalSince1970: TimeInterval(timestamp)) let dateFormatter = DateFormatter() dateFormatter.timeZone = TimeZone(abbreviation: "UTC") // or any other specific timezone let formattedDate = dateFormatter.string(from: date) return Text(formattedDate) .lineLimit(1) .font(.caption2) .foregroundColor(.secondary) .padding(.bottom, 20.0) .minimumScaleFactor(0.5) } }
Description
Not sure what the best way to handle this is, but when calling
getStatus
.onAppear
the values of latest timestamps are not available yet (nil
), but then after a few seconds they are notnil
anymore (like when a user might pull to refresh). I'm not sure the best way to handle it, I played around with a few animations, delayinggetStatus
call for 5 seconds, and none felt quite right for now.Notes to the reviewers
Changelog notice
Checklists
All Submissions:
.swift-format
fileNew Features:
Bugfixes: