File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 55 import { page } from ' $app/stores' ;
66 import { goto } from ' $app/navigation' ;
77 import { browser } from ' $app/environment' ;
8- import { onMount } from ' svelte' ;
98
109 const apiUrl = import .meta .env .VITE_API_URL || ' http://localhost:3000' ;
1110
4847 }
4948 }
5049
51- onMount (() => loadCalendars ());
52-
5350 function saveCalendars(calendarData : CalendarData ) {
5451 const calendars = Object .fromEntries (availableCalendars .map ((c ) => [c .value , c ]));
5552 Object .assign (calendars , JSON .parse (localStorage .getItem (' calendars' ) || ' {}' ));
6057 function loadCalendars() {
6158 if (localStorage .getItem (' calendars' )) {
6259 availableCalendars = Object .values (JSON .parse (localStorage .getItem (' calendars' ) || ' {}' ));
63- } else {
64- availableCalendars = defaultCalendars ;
60+ }
61+ for (const calendar of defaultCalendars ) {
62+ if (! availableCalendars .find ((c ) => c .value === calendar .value )) {
63+ availableCalendars .push (calendar );
64+ }
6565 }
6666 }
6767
7272 if (response .status === 200 ) {
7373 calendarData = await response .json ();
7474 saveCalendars (calendarData );
75+ loadCalendars ();
7576 }
7677 loading = false ;
7778 } catch (error ) {
146147 if (createdCalendars .length === 1 ) {
147148 const { token } = createdCalendars [0 ];
148149 await fetchData (token );
149- loadCalendars ();
150150 goto (` ?id=${token } ` );
151151 }
152152 } catch (error ) {
You can’t perform that action at this time.
0 commit comments