mirror of
https://github.com/bytedream/stream-bypass.git
synced 2026-08-04 21:10:40 +02:00
clean empty per site settings
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import HostsTable from '@/entrypoints/popup/pages/settings/HostsTable.svelte';
|
||||
import PerSiteDisables from '@/entrypoints/popup/pages/settings/PerSiteDisables.svelte';
|
||||
import { isMobile } from '@/entrypoints/popup/state';
|
||||
import { PerDomainSettings } from '@/lib/settings';
|
||||
|
||||
/* types */
|
||||
interface Props {
|
||||
@@ -16,6 +17,8 @@
|
||||
/* states */
|
||||
let { onSettingsCloseRequest }: Props = $props();
|
||||
let searchQuery = $state('');
|
||||
|
||||
onDestroy(PerDomainSettings.cleanEmpty);
|
||||
</script>
|
||||
|
||||
<div class="w-full">
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import PerSiteHostsList from '@/entrypoints/popup/pages/site-config/PerSiteHostsList.svelte';
|
||||
import { listenTabMessages, sendTabMessageToActiveTab, TabMessageType } from '@/lib/communication';
|
||||
import { hosts, type Host } from '@/lib/host';
|
||||
import { PerDomainSettings } from '@/lib/settings';
|
||||
|
||||
/* types */
|
||||
interface Props {
|
||||
@@ -35,7 +36,10 @@
|
||||
currentDomain = new URL(url).hostname;
|
||||
});
|
||||
|
||||
onDestroy(cancel);
|
||||
onDestroy(() => {
|
||||
cancel();
|
||||
PerDomainSettings.cleanEmpty();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="w-full">
|
||||
|
||||
@@ -108,4 +108,12 @@ export class PerDomainSettings {
|
||||
delete val[domain];
|
||||
return val;
|
||||
});
|
||||
|
||||
static cleanEmpty = () =>
|
||||
this.storage.update((val) => {
|
||||
for (const [domain, settings] of Object.entries(val)) {
|
||||
if (!settings.allDisabled && settings.disabledHostIds.length === 0) delete val[domain];
|
||||
}
|
||||
return val;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user