mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 10:39:57 +00:00
Improve options page whitelist known apps filtering
This commit is contained in:
@@ -16,8 +16,15 @@
|
|||||||
let editingInput: HTMLInputElement;
|
let editingInput: HTMLInputElement;
|
||||||
let editingValue: string;
|
let editingValue: string;
|
||||||
|
|
||||||
const knownAppsValues = Object.values(knownApps);
|
|
||||||
let knownAppToAdd: Nullable<KnownApp> = null;
|
let knownAppToAdd: Nullable<KnownApp> = null;
|
||||||
|
$: filteredKnownApps = Object.values(knownApps).filter(app => {
|
||||||
|
// If no pattern or name matches default media sender
|
||||||
|
if (!app.matches || app.name === _("popupMediaTypeAppMedia")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Filter if pattern already in whitelist
|
||||||
|
return !items.find(item => item.pattern === app.matches);
|
||||||
|
});
|
||||||
|
|
||||||
async function beginEditing(index: number) {
|
async function beginEditing(index: number) {
|
||||||
if (isEditing) return;
|
if (isEditing) return;
|
||||||
@@ -128,7 +135,7 @@
|
|||||||
on:blur={finishEditing}
|
on:blur={finishEditing}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
{@const knownApp = knownAppsValues.find(
|
{@const knownApp = Object.values(knownApps).find(
|
||||||
app => app.matches === item.pattern
|
app => app.matches === item.pattern
|
||||||
)}
|
)}
|
||||||
<div class="whitelist__pattern">
|
<div class="whitelist__pattern">
|
||||||
@@ -182,16 +189,10 @@
|
|||||||
<option value={null}>
|
<option value={null}>
|
||||||
{_("optionsSiteWhitelistKnownAppsCustomApp")}
|
{_("optionsSiteWhitelistKnownAppsCustomApp")}
|
||||||
</option>
|
</option>
|
||||||
{#each knownAppsValues as knownApp}
|
{#each filteredKnownApps as knownApp}
|
||||||
{@const isExisting = !!items.find(
|
<option value={knownApp}>
|
||||||
item => item.pattern === knownApp.matches
|
{knownApp.name}
|
||||||
)}
|
</option>
|
||||||
|
|
||||||
{#if knownApp.matches && knownApp.name !== _("popupMediaTypeAppMedia") && !isExisting}
|
|
||||||
<option value={knownApp}>
|
|
||||||
{knownApp.name}
|
|
||||||
</option>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user