feat(ui): кошелек на device.key и проверки серверов (тоже пока не проверено)

This commit is contained in:
AidarKC
2026-04-21 03:12:22 +03:00
parent 8be56192cb
commit e63c53a855
9 changed files with 588 additions and 79 deletions
+19 -6
View File
@@ -1,5 +1,6 @@
import { renderHeader } from '../components/header.js';
import { checkServerAvailability, saveEntrySettings, state } from '../state.js';
import { saveEntrySettings, state } from '../state.js';
import { checkServerAvailabilityByKey } from '../services/server-health-service.js';
export const pageMeta = { id: 'entry-settings-view', title: 'Настройки входа', showAppChrome: false };
@@ -86,9 +87,17 @@ export function render({ navigate }) {
}
};
const runCheck = () => {
const runCheck = async () => {
draft[field.key] = input.value.trim();
applyStatus(checkServerAvailability(input.value));
checkButton.disabled = true;
checkButton.textContent = 'Проверка...';
try {
const next = await checkServerAvailabilityByKey(field.key, input.value);
applyStatus(next);
} finally {
checkButton.disabled = false;
checkButton.textContent = 'Проверить';
}
};
applyStatus(draft.statuses[field.key]);
@@ -98,13 +107,17 @@ export function render({ navigate }) {
draft[field.key] = input.value;
applyStatus('idle');
window.clearTimeout(timers.get(field.key));
timers.set(field.key, window.setTimeout(runCheck, 3000));
timers.set(field.key, window.setTimeout(() => {
void runCheck();
}, 3000));
});
input.addEventListener('blur', () => {
void runCheck();
});
input.addEventListener('blur', runCheck);
input.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
event.preventDefault();
runCheck();
void runCheck();
}
});