Refine NIP-88 polls code structure and reactivity #151

Closed
opened 2026-04-04 10:00:19 +00:00 by Khushvendra · 1 comment
Contributor

The recent addition of NIP-88 Polls is a great feature (referencing issue #77 ) ! To build on that work, there are a few opportunities to streamline the component code and bring it closer to Flotilla's "Human-First Simplicity" and Svelte 5 guidelines.

This issue tracks a few minor optimizations to reduce boilerplate and performance overhead in the poll UI layer:

Proposed Improvements

  • Simplify Progress Animation: The PollOption component currently uses Svelte 4's tweened from svelte/motion combined with manual $effect wrappers to animate the progress bar. We can simplify this by natively binding the vote count to the <progress> element and letting DaisyUI handle the transitions.
  • Extract Inline Handlers: There are several inline event handlers in PollCreate and PollOption (e.g. for drag-and-drop logic). Extracting these into named functions within the <script> block will improve readability and align with our linter rules.
  • Optimize Option Sorting: The custom drag-and-drop feature in PollCreate has some verbose list-slicing logic. We should retain this convenient feature but condense the array manipulation to make it easier to maintain.
  • Remove Redundant Fetches: NoteContentPoll.svelte triggers an imperative network request inside its onMount execution. Since the space sync logic (sync.ts) already handles retrieving PollResponse events naturally, we can remove this direct fetch to preserve our unidirectional data architecture.

Additional housekeeping

Verification

  • pnpm run check
  • pnpm run lint
  • pnpm run format
The recent addition of NIP-88 Polls is a great feature (referencing issue #77 ) ! To build on that work, there are a few opportunities to streamline the component code and bring it closer to Flotilla's "Human-First Simplicity" and Svelte 5 guidelines. This issue tracks a few minor optimizations to reduce boilerplate and performance overhead in the poll UI layer: ### Proposed Improvements - **Simplify Progress Animation**: The `PollOption` component currently uses Svelte 4's `tweened` from `svelte/motion` combined with manual `$effect` wrappers to animate the progress bar. We can simplify this by natively binding the vote count to the `<progress>` element and letting DaisyUI handle the transitions. - **Extract Inline Handlers**: There are several inline event handlers in `PollCreate` and `PollOption` (e.g. for drag-and-drop logic). Extracting these into named functions within the `<script>` block will improve readability and align with our linter rules. - **Optimize Option Sorting**: The custom drag-and-drop feature in `PollCreate` has some verbose list-slicing logic. We should retain this convenient feature but condense the array manipulation to make it easier to maintain. - **Remove Redundant Fetches**: `NoteContentPoll.svelte` triggers an imperative network `request` inside its `onMount` execution. Since the space sync logic (`sync.ts`) already handles retrieving `PollResponse` events naturally, we can remove this direct fetch to preserve our unidirectional data architecture. **Additional housekeeping** - Fixed format script git ref typo (head -> HEAD) in [package.json:16](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html). **Verification** - pnpm run check - pnpm run lint - pnpm run format
Owner

I would be ok with using css to interpolate progress, but everything else is unnecessary.

I would be ok with using css to interpolate progress, but everything else is unnecessary.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coracle/flotilla#151