schoolbox web extension :)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: derive plugin and snippet ID types from configs

willow f97617c4 015d9925

+8 -13
+2 -2
src/utils/storage/plugins.ts
··· 2 2 import { StorageState } from "./state.svelte"; 3 3 import type * as Types from "./types"; 4 4 5 - export const pluginConfig: Record<Types.PluginId, Types.PluginConfig> = { 5 + export const pluginConfig: Record<string, Types.PluginConfig> = { 6 6 subheader: { 7 7 name: "Subheader Revamp", 8 8 description: "Adds a clock and current period info to the subheader.", ··· 89 89 export const plugins = buildPluginsFromConfig(pluginConfig); 90 90 91 91 function buildPluginsFromConfig( 92 - config: Record<Types.PluginId, Types.PluginConfig>, 92 + config: Record<string, Types.PluginConfig>, 93 93 ): Record<Types.PluginId, Types.PluginData> { 94 94 const plugins: Partial<Record<Types.PluginId, Types.PluginData>> = {}; 95 95
+2 -2
src/utils/storage/snippets.ts
··· 2 2 import { StorageState } from "./state.svelte"; 3 3 import type * as Types from "./types"; 4 4 5 - export const snippetConfig: Record<Types.SnippetId, Types.SnippetConfig> = { 5 + export const snippetConfig: Record<string, Types.SnippetConfig> = { 6 6 roundedCorners: { 7 7 name: "Rounded Corners", 8 8 description: "Adds rounded corners to all elements across Schoolbox.", ··· 31 31 export const snippets = buildSnippetsFromConfig(snippetConfig); 32 32 33 33 function buildSnippetsFromConfig( 34 - config: Record<Types.SnippetId, Types.SnippetConfig>, 34 + config: Record<string, Types.SnippetConfig>, 35 35 ): Record<Types.SnippetId, Types.SnippetData> { 36 36 const snippets: Partial<Record<Types.SnippetId, Types.SnippetData>> = {}; 37 37
+4 -9
src/utils/storage/types.ts
··· 1 + import type { pluginConfig } from "./plugins"; 2 + import type { snippetConfig } from "./snippets"; 1 3 import type { StorageState } from "./state.svelte"; 2 4 3 5 // Global ··· 52 54 } 53 55 54 56 // Plugins 55 - export type PluginId = 56 - | "subheader" 57 - | "scrollSegments" 58 - | "scrollPeriod" 59 - | "progressBar" 60 - | "modernIcons" 61 - | "tabTitle" 62 - | "homepageSwitcher"; 57 + export type PluginId = keyof typeof pluginConfig; 63 58 64 59 export type Toggle = { toggle: boolean }; 65 60 ··· 100 95 } & ItemInfo); 101 96 102 97 // Snippets 103 - export type SnippetId = "roundedCorners" | "hidePfp" | "hidePwaPrompt" | "censor"; 98 + export type SnippetId = keyof typeof snippetConfig; 104 99 105 100 export type SnippetData = { 106 101 toggle: StorageState<Toggle>;