mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 17:49:58 +00:00
Simplify whitelist input validity checking
This commit is contained in:
@@ -12,13 +12,11 @@
|
|||||||
export let items: WhitelistItemData[];
|
export let items: WhitelistItemData[];
|
||||||
|
|
||||||
let isEditing = false;
|
let isEditing = false;
|
||||||
|
let isEditingValid = false;
|
||||||
let editingIndex: number;
|
let editingIndex: number;
|
||||||
let editingInput: HTMLInputElement;
|
let editingInput: HTMLInputElement;
|
||||||
let editingValue: string;
|
let editingValue: string;
|
||||||
|
|
||||||
$: isEditingValid =
|
|
||||||
isEditing && REMOTE_MATCH_PATTERN_REGEX.test(editingValue);
|
|
||||||
|
|
||||||
async function beginEditing(index: number) {
|
async function beginEditing(index: number) {
|
||||||
if (isEditing) return;
|
if (isEditing) return;
|
||||||
|
|
||||||
@@ -33,7 +31,7 @@
|
|||||||
editingInput.select();
|
editingInput.select();
|
||||||
}
|
}
|
||||||
function finishEditing() {
|
function finishEditing() {
|
||||||
if (!isEditing || !editingInput.validity.valid) return;
|
if (!isEditing || !isEditingValid) return;
|
||||||
|
|
||||||
isEditing = false;
|
isEditing = false;
|
||||||
items[editingIndex].pattern = editingValue;
|
items[editingIndex].pattern = editingValue;
|
||||||
@@ -50,7 +48,7 @@
|
|||||||
: ""
|
: ""
|
||||||
);
|
);
|
||||||
|
|
||||||
isEditingValid = editingInput.checkValidity();
|
isEditingValid = editingInput.validity.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addItem() {
|
function addItem() {
|
||||||
|
|||||||
Reference in New Issue
Block a user