Skip to content

Commit 13429b8

Browse files
committed
connect: auto-create a default session when none exist
1 parent 1ce225d commit 13429b8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/src/store/stores/sessionStore.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import * as LIT from 'types/generated/lit-sessions_pb';
1010
import { IS_PROD } from 'config';
1111
import copyToClipboard from 'copy-to-clipboard';
12+
import { MAX_DATE } from 'util/constants';
1213
import { hex } from 'util/strings';
1314
import { Store } from 'store';
1415
import { Session } from '../models';
@@ -70,6 +71,15 @@ export default class SessionStore {
7071

7172
this._store.log.info('updated sessionStore.sessions', toJS(this.sessions));
7273
});
74+
75+
// Ensures that there is at least one session created
76+
if (this.sortedSessions.length === 0) {
77+
const count = values(this.sessions).filter(s =>
78+
s.label.startsWith('Default Session'),
79+
).length;
80+
const countText = count === 0 ? '' : `(${count})`;
81+
await this.addSession(`Default Session ${countText}`, MAX_DATE);
82+
}
7383
} catch (error) {
7484
this._store.appView.handleError(error, 'Unable to fetch sessions');
7585
}

0 commit comments

Comments
 (0)