-
Notifications
You must be signed in to change notification settings - Fork 11
feat: Move favorite charm logic to its own view and discerns between local and remote state #2181
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
Conversation
045c218 to
cf12ab0
Compare
cf12ab0 to
f7d9ab1
Compare
7b42618 to
fbfffea
Compare
67e2dfb to
d6e959c
Compare
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.
1 issue found across 5 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/shell/src/components/FavoriteButton.ts">
<violation number="1" location="packages/shell/src/components/FavoriteButton.ts:53">
P2: Ensure the sync task runs even when the favorite mutation fails so the optimistic state doesn’t stay stuck after an error.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| this.isFavoriteSync.run(); | ||
| } | ||
|
|
||
| protected override willUpdate(changedProperties: PropertyValues): void { | ||
| if (changedProperties.has("charmId")) { | ||
| this.isFavorite = undefined; | ||
| } | ||
| } |
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.
P2: Ensure the sync task runs even when the favorite mutation fails so the optimistic state doesn’t stay stuck after an error.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/shell/src/components/FavoriteButton.ts, line 53:
<comment>Ensure the sync task runs even when the favorite mutation fails so the optimistic state doesn’t stay stuck after an error.</comment>
<file context>
@@ -0,0 +1,127 @@
+ await manager.addFavorite(charmCell);
+ }
+
+ this.isFavoriteSync.run();
+ }
+
</file context>
| this.isFavoriteSync.run(); | |
| } | |
| protected override willUpdate(changedProperties: PropertyValues): void { | |
| if (changedProperties.has("charmId")) { | |
| this.isFavorite = undefined; | |
| } | |
| } | |
| try { | |
| const charmCell = (await this.rt.cc().get(this.charmId, true)).getCell(); | |
| if (isFavorite) { | |
| await manager.removeFavorite(charmCell); | |
| } else { | |
| await manager.addFavorite(charmCell); | |
| } | |
| } finally { | |
| this.isFavoriteSync.run(); | |
| } |
bfollington
left a comment
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.
Nice, definitely better to have this all bundled in one place. LGTM.
…local modification and server state.
d6e959c to
3278376
Compare
Summary by cubic
Moved favorite charm handling into a dedicated FavoriteButton component with optimistic local state and server sync. Simplifies the header and removes the toggle-favorite command from the command pipeline.
New Features
Refactors
Written for commit 3278376. Summary will update automatically on new commits.