feat(sticker): add stickerId to StickerItem and related components#1885
feat(sticker): add stickerId to StickerItem and related components#1885
Conversation
2ef79d4 to
58ae825
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds stickerId parameter to the StickerItem widget and related components to enable automatic refresh of sticker data when loading fails. It also refactors the UpdateStickerJob to include retry logic with exponential backoff.
Changes:
- Added
stickerIdparameter toStickerItemand updated all call sites to pass this parameter - Implemented error recovery in
StickerItemthat triggers a refresh job when sticker loading fails - Refactored
UpdateStickerJobto process jobs sequentially with retry logic and exponential backoff - Updated database queries to filter jobs with null
blazeMessageand order bycreatedAt - Enhanced
sticker_message.dartto immediately yield cached data while watching for updates - Added sticker data watching in
quote_message.dartfor up-to-date quoted stickers - Updated Xcode project configuration for Flutter compatibility
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| macos/Runner.xcodeproj/project.pbxproj | Updated Xcode objectVersion and shell scripts for Flutter compatibility |
| lib/workers/job/update_sticker_job.dart | Refactored to process jobs sequentially with retry logic and exponential backoff |
| lib/widgets/sticker_page/sticker_item.dart | Added stickerId parameter and error handling to trigger refresh jobs |
| lib/widgets/sticker_page/sticker_store.dart | Updated StickerItem usages to pass stickerId |
| lib/widgets/sticker_page/sticker_page.dart | Updated StickerItem usage to pass stickerId |
| lib/widgets/sticker_page/sticker_album_page.dart | Updated StickerItem usage to pass stickerId |
| lib/widgets/message/send_message_dialog/send_message_dialog.dart | Updated StickerItem usage to pass stickerId |
| lib/widgets/message/item/sticker_message.dart | Refactored stream to yield cached data immediately while watching for updates |
| lib/widgets/message/item/quote_message.dart | Added sticker data watching and updated StickerItem to pass stickerId |
| lib/db/dao/job_dao.dart | Updated query to filter null blazeMessage and order by createdAt |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| final now = DateTime.now(); | ||
| final first = jobs.first; | ||
| final wait = first.createdAt.difference(now); |
There was a problem hiding this comment.
The time difference calculation is incorrect. The code calculates first.createdAt.difference(now), which subtracts now from first.createdAt. This will produce a negative duration if first.createdAt is in the past (which is the typical case for a job that was created earlier). The check if (wait.inMilliseconds > 0) will be false for past timestamps, but the logic should be checking if the job is scheduled for the future. Consider using now.difference(first.createdAt) instead, or restructure the logic to check if first.createdAt.isAfter(now).
| } | ||
|
|
||
| for (final job in jobs) { | ||
| final dueIn = job.createdAt.difference(DateTime.now()); |
There was a problem hiding this comment.
The time difference calculation has the same issue as line 47. This calculates job.createdAt.difference(DateTime.now()), which will be negative for jobs created in the past. The condition if (dueIn.inMilliseconds > 0) will never be true for past timestamps, making this check ineffective. The logic should be restructured to check if job.createdAt.isAfter(DateTime.now()) or use DateTime.now().difference(job.createdAt) with appropriate logic reversal.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.