fix: filter status entries from visible sessions — no more duplicate blank/offline tiles
Unreachable/auth_failed status entries from the federation response were rendered twice: once as a blank session tile (no name) by buildTileHTML, and again as an 'Offline' status tile by the separate status rendering loop. Fix: getVisibleSessions() now filters out entries with a status field. Status tiles are still rendered separately from the full sessions array.
This commit is contained in:
@@ -530,6 +530,8 @@ function buildStatusTileHTML(deviceName, statusText, statusClass) {
|
||||
function getVisibleSessions(sessions) {
|
||||
var hidden = (_serverSettings && _serverSettings.hidden_sessions) || [];
|
||||
return (sessions || []).filter(function(s) {
|
||||
// Skip status entries (unreachable, auth_failed) — rendered separately as status tiles
|
||||
if (s.status) return false;
|
||||
if (hidden.length > 0 && hidden.includes(s.name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1769,6 +1769,37 @@ test('renderSidebar does nothing when view is not fullscreen', () => {
|
||||
globalThis.document.getElementById = origGetById;
|
||||
});
|
||||
|
||||
// --- getVisibleSessions ---
|
||||
|
||||
test('getVisibleSessions filters out entries with unreachable status (no name)', () => {
|
||||
const sessions = [
|
||||
{ name: 'real-session', snapshot: '' },
|
||||
{ status: 'unreachable', remoteId: 0, deviceName: 'alienware-r13' },
|
||||
];
|
||||
const result = app.getVisibleSessions(sessions);
|
||||
assert.strictEqual(result.length, 1, 'should return only the real session');
|
||||
assert.strictEqual(result[0].name, 'real-session');
|
||||
});
|
||||
|
||||
test('getVisibleSessions filters out entries with auth_failed status', () => {
|
||||
const sessions = [
|
||||
{ name: 'real-session', snapshot: '' },
|
||||
{ name: 'Workstation', status: 'auth_failed' },
|
||||
];
|
||||
const result = app.getVisibleSessions(sessions);
|
||||
assert.strictEqual(result.length, 1, 'auth_failed entry should be filtered out');
|
||||
assert.strictEqual(result[0].name, 'real-session');
|
||||
});
|
||||
|
||||
test('getVisibleSessions passes through sessions with no status field', () => {
|
||||
const sessions = [
|
||||
{ name: 'alpha', snapshot: '' },
|
||||
{ name: 'beta', snapshot: '' },
|
||||
];
|
||||
const result = app.getVisibleSessions(sessions);
|
||||
assert.strictEqual(result.length, 2, 'normal sessions should all pass through');
|
||||
});
|
||||
|
||||
// ─── initSidebar ─────────────────────────────────────────────────────────────
|
||||
|
||||
test('initSidebar defaults to open (removes sidebar--collapsed) on wide screens when no stored value', () => {
|
||||
|
||||
Reference in New Issue
Block a user