chore: refine NIP-88 polls code structure and reactivity #153
Reference in New Issue
Block a user
Delete Branch "Khushvendra/flotilla:chore/nip-88-polls-simplify"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
This PR addresses the code-style and reactivity overhead issues outlined in #151, bringing the NIP-88 Polls implementation fully in line with Flotilla's "Human-First Simplicity" and Svelte 5 guidelines. It reduces bundle bloat, cleans up component-level state, and removes unnecessary network fetches.
Resolves #151.
Changes Included
tweenedfromsvelte/motionand its manual$effectsync wrappers inPollOption.svelte. The progress bar now natively binds to the$derivedvote count, leaning on the browser for rendering.PollCreate.svelteandPollOption.svelteinto explicitly named functions in the<script>block, adhering to Flotilla's strictly defined event handler rules.PollCreate.svelte, removing unused@welshman/libimports likeremoveAtandinsertAtfor much more readable state logic.requestinsideonMountwithinNoteContentPoll.svelte. It was redundant and caused over-fetching since space sync (sync.ts) handles fetching and listening forPollResponseevents naturally via the background logic constraint.Validation
pnpm run check) and linter tests all pass cleanly.PollCreatefunctions seamlessly after optimizations.<progress>correctly scales itsmaxandvalueon incoming poll votes.This is not a good PR:
@@ -17,4 +7,0 @@relays: [props.url],filters: [{kinds: [PollResponse], "#e": [props.event.id]}],})})We actually do need this, sync is only a best-effort thing to speed up page transitions.
@@ -68,0 +68,4 @@const sourceOption = reordered[sourceIndex]reordered[sourceIndex] = reordered[targetIndex]reordered[targetIndex] = sourceOptionoptions = reorderedI think insertAt/removeAt is actually much cleaner
Pull request closed