Skip to content

Commit bbddfab

Browse files
Handle session templates properly
They don't have an ID, so they would crash the sessions page. Now they get shown properly as templated sessions that are not yet started.
1 parent ae102b3 commit bbddfab

1 file changed

Lines changed: 31 additions & 17 deletions

File tree

src/pages/sessions/sessionlist.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,37 @@ const SessionTable = ({sessions}) => {
3535
</tr>
3636
</thead>
3737
<tbody>
38-
{sessions.map(s => <tr key={s.id}>
39-
<td><Link to={`${path}${s.id}`}>{s.title || "(untitled)"}</Link></td>
40-
<td><Link to={`${path}${s.id}`}><abbr title={s.id}>{s.id.substr(0, 8)}...</abbr></Link></td>
41-
<td><Link to={`${path}${s.id}`}>{s.alias}</Link></td>
42-
<td>{s.userCount} / {s.maxUserCount}</td>
43-
<td>
44-
{s.hasPassword && <span title="Password">🔒</span>}
45-
{s.closed && <span title="Closed to new users">🚪</span>}
46-
{s.authOnly && <span title="Registered users only">👥</span>}
47-
{s.persistent && <span title="Persists without users">💾</span>}
48-
{s.nsfm && <span title="Not suitable for minors (NSFM)">🔞</span>}
49-
{s.idleOverride && <span title="Ignores idle timeout"></span>}
50-
{s.allowWeb && <span title="Allow joining via WebSocket">🌐</span>}
51-
</td>
52-
<td>{(s.size / (1024 *1024)).toFixed(2)} MB</td>
53-
<td>{s.startTime}</td>
54-
</tr>)}
38+
{sessions.map(s => {
39+
const title = s.title || "(untitled)";
40+
return <tr key={s.id}>
41+
<td>
42+
{s.id ? <Link to={`${path}${s.id}`}>{title}</Link> : title}
43+
</td>
44+
<td>
45+
{s.id ? <Link to={`${path}${s.id}`}><abbr title={s.id}>{s.id.substr(0, 8)}...</abbr></Link> : "(template)"}
46+
</td>
47+
<td>
48+
{s.id ? <Link to={`${path}${s.id}`}>{s.alias}</Link> : s.alias}
49+
</td>
50+
<td>
51+
{s.userCount || 0} / {s.maxUserCount || 254}
52+
</td>
53+
<td>
54+
{s.hasPassword && <span title="Password">🔒</span>}
55+
{s.closed && <span title="Closed to new users">🚪</span>}
56+
{s.authOnly && <span title="Registered users only">👥</span>}
57+
{s.persistent && <span title="Persists without users">💾</span>}
58+
{s.nsfm && <span title="Not suitable for minors (NSFM)">🔞</span>}
59+
{s.idleOverride && <span title="Ignores idle timeout"></span>}
60+
{s.allowWeb && <span title="Allow joining via WebSocket">🌐</span>}
61+
</td>
62+
<td>
63+
{((s.size || 0) / (1024 * 1024)).toFixed(2)} MB</td>
64+
<td>
65+
{s.startTime || "not started"}
66+
</td>
67+
</tr>;
68+
})}
5569
</tbody>
5670
</table>
5771
}

0 commit comments

Comments
 (0)