mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
fix: standalone not correctly being set
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { animate, spring } from 'motion';
|
import { animate, spring } from 'motion';
|
||||||
import { createStandalone } from '../utils/standalone.svelte'
|
import { standalone } from '../utils/standalone.svelte'
|
||||||
|
|
||||||
let { state, onChange } = $props<{ state: boolean, onChange: (newState: boolean) => void }>();
|
let { state, onChange } = $props<{ state: boolean, onChange: (newState: boolean) => void }>();
|
||||||
let handle: HTMLElement | null = null;
|
let handle: HTMLElement | null = null;
|
||||||
let standalone = createStandalone();
|
|
||||||
|
|
||||||
const springParams = {
|
const springParams = {
|
||||||
stiffness: 600,
|
stiffness: 600,
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import "./index.css"
|
|||||||
import { mount } from "svelte"
|
import { mount } from "svelte"
|
||||||
import type { ComponentType } from "svelte"
|
import type { ComponentType } from "svelte"
|
||||||
import Settings from "./pages/settings.svelte"
|
import Settings from "./pages/settings.svelte"
|
||||||
|
import IconFamily from '@/resources/fonts/IconFamily.woff'
|
||||||
|
import browser from "webextension-polyfill"
|
||||||
|
|
||||||
export default function renderSvelte(
|
export default function renderSvelte(
|
||||||
Component: ComponentType | any,
|
Component: ComponentType | any,
|
||||||
@@ -19,10 +21,26 @@ export default function renderSvelte(
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function InjectCustomIcons() {
|
||||||
|
console.info('[BetterSEQTA+] Injecting Icons')
|
||||||
|
|
||||||
|
const style = document.createElement('style')
|
||||||
|
style.setAttribute('type', 'text/css')
|
||||||
|
style.innerHTML = `
|
||||||
|
@font-face {
|
||||||
|
font-family: 'IconFamily';
|
||||||
|
src: url('${browser.runtime.getURL(IconFamily)}') format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}`
|
||||||
|
document.head.appendChild(style)
|
||||||
|
}
|
||||||
|
|
||||||
const mountPoint = document.getElementById('app')
|
const mountPoint = document.getElementById('app')
|
||||||
if (!mountPoint) {
|
if (!mountPoint) {
|
||||||
console.error('Mount point #app not found')
|
console.error('Mount point #app not found')
|
||||||
throw new Error('Mount point #app not found')
|
throw new Error('Mount point #app not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InjectCustomIcons()
|
||||||
renderSvelte(Settings, mountPoint)
|
renderSvelte(Settings, mountPoint)
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
import Theme from './settings/theme.svelte';
|
import Theme from './settings/theme.svelte';
|
||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
|
|
||||||
import { createStandalone } from '../utils/standalone.svelte';
|
import { standalone as StandaloneStore } from '../utils/standalone.svelte';
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { initializeSettingsState, settingsState } from '@/seqta/utils/listeners/SettingsState'
|
import { initializeSettingsState, settingsState } from '@/seqta/utils/listeners/SettingsState'
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
closeExtensionPopup();
|
closeExtensionPopup();
|
||||||
};
|
};
|
||||||
|
|
||||||
let { standalone = false } = $props<{ standalone?: boolean }>();
|
let { standalone } = $props<{ standalone?: boolean }>();
|
||||||
let showColourPicker = $state<boolean>(false);
|
let showColourPicker = $state<boolean>(false);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -56,10 +56,7 @@
|
|||||||
|
|
||||||
if (!standalone) return;
|
if (!standalone) return;
|
||||||
initializeSettingsState();
|
initializeSettingsState();
|
||||||
// @ts-ignore
|
StandaloneStore.setStandalone(true);
|
||||||
let globalStandalone = createStandalone();
|
|
||||||
globalStandalone = standalone;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,36 @@
|
|||||||
export function createStandalone() {
|
import type { Subscriber, Unsubscriber } from "svelte/store";
|
||||||
let standalone = $state(false);
|
|
||||||
|
|
||||||
function setStandalone(value: boolean) {
|
export class Standalone {
|
||||||
standalone = value;
|
private static instance: Standalone;
|
||||||
|
private _standalone = $state(false);
|
||||||
|
private subscribers = new Set<Subscriber<boolean>>();
|
||||||
|
|
||||||
|
private constructor() {}
|
||||||
|
|
||||||
|
public static getInstance(): Standalone {
|
||||||
|
if (!Standalone.instance) {
|
||||||
|
Standalone.instance = new Standalone();
|
||||||
|
}
|
||||||
|
return Standalone.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
public setStandalone(value: boolean) {
|
||||||
get standalone() {
|
this._standalone = value;
|
||||||
return standalone;
|
this.subscribers.forEach(subscriber => subscriber(value));
|
||||||
},
|
}
|
||||||
setStandalone
|
|
||||||
};
|
public get standalone() {
|
||||||
|
return this._standalone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public subscribe(run: Subscriber<boolean>): Unsubscriber {
|
||||||
|
this.subscribers.add(run);
|
||||||
|
run(this._standalone);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
this.subscribers.delete(run);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const standalone = createStandalone();
|
export const standalone = Standalone.getInstance();
|
||||||
Reference in New Issue
Block a user