From 07f32f8e956c3d3dc289654474b6c2d4788c2b0e Mon Sep 17 00:00:00 2001 From: Egor Aristov Date: Tue, 6 May 2025 23:35:28 +0300 Subject: [PATCH] small refactoring --- frontend/wizard-vue/src/stores/wizard.ts | 6 +++--- frontend/wizard-vue/src/urlmaker/index.ts | 6 +++--- frontend/wizard-vue/src/urlmaker/specs.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/wizard-vue/src/stores/wizard.ts b/frontend/wizard-vue/src/stores/wizard.ts index 18beaee..ff880ac 100644 --- a/frontend/wizard-vue/src/stores/wizard.ts +++ b/frontend/wizard-vue/src/stores/wizard.ts @@ -1,5 +1,5 @@ import {defineStore} from "pinia"; -import {emptySpecs, type SpecField, fields, type Specs, type SpecValue} from "@/urlmaker/specs.ts"; +import {defaultSpecs, type SpecField, fields, type Specs, type SpecValue} from "@/urlmaker/specs.ts"; import {computed, reactive} from "vue"; import {debounce} from "es-toolkit"; @@ -8,7 +8,7 @@ const LOCAL_STORAGE_KEY = 'rssalchemy_store_wizard'; export const useWizardStore = defineStore('wizard', () => { const locStorageContent = localStorage.getItem(LOCAL_STORAGE_KEY); - const initialSpecs = locStorageContent ? JSON.parse(locStorageContent) as Specs : emptySpecs; + const initialSpecs = locStorageContent ? JSON.parse(locStorageContent) as Specs : defaultSpecs; const specs = reactive(Object.assign({}, initialSpecs)); @@ -31,7 +31,7 @@ export const useWizardStore = defineStore('wizard', () => { updateLocalStorage(); } function reset() { - Object.assign(specs, emptySpecs); + Object.assign(specs, defaultSpecs); updateLocalStorage(); } diff --git a/frontend/wizard-vue/src/urlmaker/index.ts b/frontend/wizard-vue/src/urlmaker/index.ts index 9049ddf..999fc25 100644 --- a/frontend/wizard-vue/src/urlmaker/index.ts +++ b/frontend/wizard-vue/src/urlmaker/index.ts @@ -1,6 +1,6 @@ -import type {Specs} from "@/urlmaker/specs.ts"; +import {type Specs} from "@/urlmaker/specs.ts"; import {b64decode, b64encode, compress, decompress, decompressString} from "@/urlmaker/utils.ts"; -import {rssalchemy as pb} from '@/urlmaker/proto/specs.ts'; +import {rssalchemy, rssalchemy as pb} from '@/urlmaker/proto/specs.ts'; const apiBase = import.meta.env.VITE_API_BASE || document.location.origin; const renderEndpoint = '/api/v1/render/'; // trailing slash @@ -57,7 +57,7 @@ export async function encodePreset(specs: Specs): Promise { } export async function encodeSpecsPart(specs: Specs): Promise { - const pbSpecs = pb.Specs.fromObject(specs); + const pbSpecs = pb.Specs.fromObject(specs as ReturnType); let data = pbSpecs.serializeBinary(); data = await compress(data); const encodedData = b64encode(data); diff --git a/frontend/wizard-vue/src/urlmaker/specs.ts b/frontend/wizard-vue/src/urlmaker/specs.ts index 10da8c1..c84db86 100644 --- a/frontend/wizard-vue/src/urlmaker/specs.ts +++ b/frontend/wizard-vue/src/urlmaker/specs.ts @@ -130,7 +130,7 @@ export const fields: SpecField[] = [ }, ]; -export const emptySpecs = fields.reduce((o, f) => { +export const defaultSpecs = fields.reduce((o, f) => { o[f.name] = f.default; return o }, {} as Specs);