OpenVAA / voting-advice-application

An open-source platform for creating Voting Advice Applications (VAAs)
https://demo.openvaa.org/
GNU General Public License v3.0
8 stars 0 forks source link

refactor: convert results tab persisting to use Snapshot #568

Closed kaljarv closed 1 week ago

kaljarv commented 2 weeks ago

I tested this by adding following code to the start of (voters)/results/+page.svelte, removing import for activeTab store and changing every $activeTab to activeTab.

import type {Snapshot} from './$types';

let activeTab = 0;

export const snapshot: Snapshot<number> = {
  capture: () => activeTab,
  restore: (value) => (activeTab = value)
};

The biggest difference compared to the store is that the active tab is persisted also when the page is refreshed. Otherwise it seems to be functionally same as the store. Visually there are two differences:

Of course it may be possible to fix these as this was only a quick test.