fix: remove dead sessions variable and add committed guard to prevent double-commit in commitRename
- Remove unused 'sessions' variable in renderViewsSettingsTab() forEach loop (was declared but never used; sessionCount already derived from view.sessions directly) - Add 'committed' flag to commitRename() closure to prevent duplicate PATCH requests when Enter-triggered DOM teardown fires blur on the still-live input (pattern mirrors the 150ms guard already used in showNewViewInput())
This commit is contained in:
@@ -1019,8 +1019,6 @@ function renderViewsSettingsTab() {
|
|||||||
// Build the list of view rows
|
// Build the list of view rows
|
||||||
listEl.innerHTML = '';
|
listEl.innerHTML = '';
|
||||||
views.forEach(function(view, idx) {
|
views.forEach(function(view, idx) {
|
||||||
var sessions = (_serverSettings && _serverSettings.sessions) || [];
|
|
||||||
// Count sessions that belong to this view
|
|
||||||
var viewSessions = view.sessions || [];
|
var viewSessions = view.sessions || [];
|
||||||
var sessionCount = viewSessions.length;
|
var sessionCount = viewSessions.length;
|
||||||
|
|
||||||
@@ -1177,7 +1175,9 @@ function renderViewsSettingsTab() {
|
|||||||
input.focus();
|
input.focus();
|
||||||
input.select();
|
input.select();
|
||||||
|
|
||||||
|
var committed = false;
|
||||||
function commitRename() {
|
function commitRename() {
|
||||||
|
if (committed) return;
|
||||||
var newName = input.value.trim();
|
var newName = input.value.trim();
|
||||||
if (!newName || newName === currentName) {
|
if (!newName || newName === currentName) {
|
||||||
renderViewsSettingsTab();
|
renderViewsSettingsTab();
|
||||||
@@ -1197,6 +1197,7 @@ function renderViewsSettingsTab() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update the view name
|
// Update the view name
|
||||||
|
committed = true;
|
||||||
var updated = views.map(function(v, i) {
|
var updated = views.map(function(v, i) {
|
||||||
return i === idx ? Object.assign({}, v, { name: newName }) : v;
|
return i === idx ? Object.assign({}, v, { name: newName }) : v;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user