fix: setFromObject() silently drops an image watermark (#95) - #96
Merged
Conversation
QuoteData.watermark/.watermarkImage split a watermark into its text and image halves, but QuoteInput (accepted by setFromObject()/applyInput()) only ever read input.watermark. A QuoteData object round-tripped through getData() -> setFromObject() always carries watermark: '' alongside a set watermarkImage for an image watermark, so applyInput() overwrote the image with that blank string and drew nothing. QuoteInput now also accepts watermarkImage, symmetric with what getData() produces; applyInput() prefers it when truthy so the round trip works without the caller having to reassemble the two fields by hand, and still falls through to the existing watermark handling for every other input shape. Fixes #95.
theme.watermark.size is tuned for a short text tag and reads too small for a logo image drawn at the same height. Adds an optional theme.watermark.imageSize (null by default, falling back to size exactly as before) so an image watermark can be sized on its own without moving the text one. Addresses the enhancement half of #95.
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.
Summary
Closes #95.
QuoteDatasplits a watermark intowatermark(text) andwatermarkImage(image) halves, butapplyInput()(used bysetFromObject()) only ever readinput.watermark. AQuoteDataround-tripped throughgetData()->setFromObject()always carrieswatermark: ''alongside a setwatermarkImagefor an image watermark, so the blank string silently overwrote the image and nothing was drawn.QuoteInputnow also acceptswatermarkImage, symmetric with whatgetData()produces.applyInput()prefers it when truthy, and still falls through to the existingwatermarkhandling (text, image, ornullto clear) for every other input shape — includingwatermarkImage: nullon its own, and a plainwatermarkImagewith nowatermarkfield at all.theme.watermark.sizeis tuned for a short text tag and reads small for a logo image drawn at the same height. Addedtheme.watermark.imageSize(nullby default, falling back tosizeexactly as before — no visual change unless you opt in) so an image watermark can be sized independently of the text one.Investigation
Looked for the same "split-field silently dropped on round-trip" pattern elsewhere in
QuoteData/QuoteInput(avatar, username, displayName, markdown) and in the source adapters (fromMessage/fromNote/fromTweet) and the CLI's own watermark flag handling —watermark/watermarkImageis the only field pair with this split representation, and the CLI resolves its--watermark/--watermark-imageflags into the singlewatermarkfield before callingsetFromObject(), so it never hit this bug. No other instance found.Test plan
npm run ci(biome)npm run typechecknpm run test(872 tests, all green; 5 new regression tests, each verified red against the pre-fix code then green after)npm run buildnpm run check:build(27 checks passed)