11import { defineStore } from 'pinia' ;
2+ import { useSettingsStore } from './settings' ;
23
34interface IElement {
45 type : string ;
56 size ?: number ;
67 props ?: Record < string , unknown > ;
78}
89
9- interface View {
10+ export interface View {
1011 id : string ;
1112 name : string ;
1213 elements : IElement [ ] ;
@@ -66,8 +67,8 @@ const androidViews = [
6667 } ,
6768] ;
6869
69- // FIXME: Decide depending on what kind of device is being viewed, not from which device it is being viewed.
70- const defaultViews = ! process . env . VUE_APP_ON_ANDROID ? desktopViews : androidViews ;
70+ // FIXME: Decide depending on what kind of device is being viewed, not from which device it is being viewed from .
71+ export const defaultViews = ! process . env . VUE_APP_ON_ANDROID ? desktopViews : androidViews ;
7172
7273interface State {
7374 views : View [ ] ;
@@ -82,21 +83,14 @@ export const useViewsStore = defineStore('views', {
8283 } ,
8384 actions : {
8485 async load ( ) {
85- let views : View [ ] ;
86- if ( typeof localStorage !== 'undefined' ) {
87- const views_json : string = localStorage . views ;
88- if ( views_json && views_json . length >= 1 ) {
89- views = JSON . parse ( views_json ) ;
90- }
91- }
92- if ( ! views ) {
93- views = defaultViews ;
94- }
86+ const settingsStore = useSettingsStore ( ) ;
87+ await settingsStore . ensureLoaded ( ) ;
88+ const views = settingsStore . views ;
9589 this . loadViews ( views ) ;
9690 } ,
9791 async save ( ) {
98- localStorage . views = JSON . stringify ( this . views ) ;
99- // After save, reload views from localStorage
92+ const settingsStore = useSettingsStore ( ) ;
93+ settingsStore . update ( { views : this . views } ) ;
10094 await this . load ( ) ;
10195 } ,
10296 loadViews ( views : View [ ] ) {
0 commit comments