Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit dd795ed

Browse files
committed
import store
1 parent 7519605 commit dd795ed

File tree

5 files changed

+116
-168
lines changed

5 files changed

+116
-168
lines changed

src/App.svelte

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
import { onMount } from 'svelte';
33
44
import allThemes from './assets/themes.json';
5-
// import {app} from '../src2/$app';
5+
import { app } from '~store.ts';
66
// import Panel from '~src/components/Panel.svelte';
77
import Loading from '~components/Loading.svelte';
88
99
onMount(async _ => {
10-
// $app.loading = true;
11-
// // Just waiting
12-
// await new Promise(resolve => setTimeout(resolve, 1000));
13-
// // Now fetching
10+
$app.loading = true;
11+
// Just waiting
12+
await new Promise(resolve => setTimeout(resolve, 1000));
13+
// Now fetching
1414
const themes = [
1515
...allThemes.material,
1616
...allThemes.other
1717
];
18-
//
19-
// // Load themes
20-
// $app.loadThemes(themes);
21-
// // Get settings from local storage
22-
// await $app.fetchSettings();
23-
// // Add defaults
24-
// $app.loadDefaults();
25-
//
26-
// $app.loading = false;
18+
19+
// Load themes
20+
$app.loadThemes(themes);
21+
// Get settings from local storage
22+
await $app.fetchSettings();
23+
// Add defaults
24+
$app.loadDefaults();
25+
26+
$app.loading = false;
2727
});
2828
</script>
2929

@@ -42,7 +42,7 @@
4242

4343
<main class='main'>
4444
<Loading></Loading>
45-
<!-- {#if !$app.loading}-->
46-
<!-- <Panel></Panel>-->
47-
<!-- {/if}-->
45+
{#if !$app.loading}
46+
<!-- <Panel></Panel>-->
47+
{/if}
4848
</main>

src2/main.js renamed to src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ const app = new App({
55
hydrate: true,
66
});
77

8-
export default app;
8+
export default app;

src2/storage.js renamed to src/storage.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Theme } from '~types/types';
2+
13
export const SETTINGS = 'devtools-settings';
24
export const DEVTOOLS_THEME = 'devtools-theme';
35
export const DEVTOOLS_FONT = 'devtools-font';
@@ -7,9 +9,18 @@ export const DEVTOOLS_ACCENT_COLOR = 'devtools-accent-color';
79
export const DEVTOOLS_SCROLLBARS = 'devtools-scrollbars';
810

911
const chromeStorage = chrome.storage && chrome.storage.sync;
10-
const fakeStorage = {
1112

12-
async get(property, fn = () => {}) {
13+
export type DevtoolsSettings = {
14+
[DEVTOOLS_THEME]?: string;
15+
[DEVTOOLS_FONT]?: string;
16+
[DEVTOOLS_SIZE]?: number;
17+
[DEVTOOLS_CURRENT]?: Theme;
18+
[DEVTOOLS_ACCENT_COLOR]?: string;
19+
[DEVTOOLS_SCROLLBARS]?: boolean;
20+
};
21+
22+
const fakeStorage = {
23+
async get(property: string, fn = (object: DevtoolsSettings) => {}) {
1324
let item = await localStorage.getItem(SETTINGS);
1425
try {
1526
const settings = item ? JSON.parse(item) : {};
@@ -19,14 +30,14 @@ const fakeStorage = {
1930
}
2031
},
2132

22-
set(settings, fn = () => {}) {
33+
set(settings: DevtoolsSettings, fn = (object: DevtoolsSettings) => {}) {
2334
let oldItem = localStorage.getItem(SETTINGS) || '{}';
2435
try {
2536
const oldSettings = JSON.parse(oldItem);
26-
const newSettings = {...oldSettings, ...settings};
37+
const newSettings = { ...oldSettings, ...settings };
2738

2839
if (chromeStorage) {
29-
chromeStorage.set({[SETTINGS]: JSON.stringify(newSettings)}, () => {});
40+
chromeStorage.set({ [SETTINGS]: JSON.stringify(newSettings) }, () => {});
3041
}
3142
localStorage.setItem(SETTINGS, JSON.stringify(newSettings));
3243
fn(settings);

0 commit comments

Comments
 (0)