Repository navigation
Fix bookmarklet saving the same post twice - #212
Merged
Merged
Conversation
The Quick Add page is rendered with InteractiveServer and prerendering, so two component instances ran OnParametersSetAsync and each called ExtractPostDetailsAndSave, which mints a new RowKey per call. - QuickAdd skips the save while prerendering (RendererInfo.IsInteractive) and shows the progress spinner; the interactive render does the save. - The extractPostDetails endpoint returns the existing post when one is already stored for the URL, so repeat requests never add a duplicate. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014Yup1wuZFURs47VNTrAK7g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Frank · project thread
Fixes #211
Before: clicking the bookmarklet opened Quick Add and the post showed up twice in the library.
After: the bookmarklet saves exactly one post. Opening Quick Add again for a URL that is already saved shows the existing post instead of adding another copy.
The page is prerendered and then rendered again once the interactive circuit connects, and each pass called the extract-and-save API, which creates a new row every time.
How
QuickAdd.razorchecksRendererInfo.IsInteractiveand, while prerendering, only shows the progress spinner; the save runs once, in the interactive render. The MAUI app's BlazorWebView is always interactive, so it is unaffected.POST /api/posts/extractPostDetailsnow looks up the URL first (newDataStorageService.GetPostByUrl) and returns the stored post if there is one. This also protects the Posts page and suggestion list, which call the same API. Re-adding an already read post returns that post rather than creating a fresh unread one.Tests
QuickAddTests: new test renders the page in prerender mode and then interactive mode and asserts a single save; another asserts the prerender pass shows the spinner and does not save. Both fail onv-nextand pass here. Existing tests now set an interactive renderer.PostEndpointsTests: calling extract twice for the same URL returns the same post and stores one row (fails onv-next, passes here).DataStorageServiceTests:GetPostByUrlfound / not found.ExtractPostDetails_WithValidUrl_ReturnsOkWithPost, which needs to fetch docs.microsoft.com, and a cross-test data leak caused by sharing one emulator across test classes. CI uses per-class containers.Existing posts already saved twice are not cleaned up (out of scope per the issue).
🤖 Generated with Claude Code
https://claude.ai/code/session_014Yup1wuZFURs47VNTrAK7g
Generated by Claude Code