@@ -39,11 +39,23 @@ export default class SessionStore {
39
39
return descending ? sessions . reverse ( ) : sessions ;
40
40
}
41
41
42
+ /** The list of sessions that have not been paired */
43
+ get unpairedSessions ( ) {
44
+ return this . sortedSessions . filter ( s => ! s . isPaired ) ;
45
+ }
46
+
42
47
/** indicates if there are more than one sessions active */
43
48
get hasMultiple ( ) {
44
49
return this . sortedSessions . length > 1 ;
45
50
}
46
51
52
+ /** The URl to pair with Terminal Web for the first session */
53
+ get firstSessionTerminalUrl ( ) {
54
+ return this . unpairedSessions . length > 0
55
+ ? this . unpairedSessions [ 0 ] . terminalConnectUrl
56
+ : '' ;
57
+ }
58
+
47
59
/**
48
60
* queries the LIT api to fetch the list of sessions and stores them
49
61
* in the state
@@ -78,7 +90,7 @@ export default class SessionStore {
78
90
} ) ;
79
91
80
92
// Ensures that there is at least one session created
81
- if ( this . sortedSessions . length === 0 ) {
93
+ if ( this . unpairedSessions . length === 0 ) {
82
94
const count = values ( this . sessions ) . filter ( s =>
83
95
s . label . startsWith ( 'Default Session' ) ,
84
96
) . length ;
@@ -99,11 +111,13 @@ export default class SessionStore {
99
111
* @param label the user defined label for this session
100
112
* @param type the type of session being created (admin, read-only, etc)
101
113
* @param expiry how long the session should be valid for
114
+ * @param copy copy the session's phrase to the clipboard
102
115
*/
103
116
async addSession (
104
117
label : string ,
105
118
type : LIT . SessionTypeMap [ keyof LIT . SessionTypeMap ] ,
106
119
expiry : Date ,
120
+ copy = false ,
107
121
) {
108
122
try {
109
123
this . _store . log . info ( `submitting session with label ${ label } ` , {
@@ -124,7 +138,7 @@ export default class SessionStore {
124
138
// fetch all sessions to update the store's state
125
139
await this . fetchSessions ( ) ;
126
140
127
- if ( session ) {
141
+ if ( session && copy ) {
128
142
this . copyPhrase ( session . label , session . pairingSecretMnemonic ) ;
129
143
return this . sessions . get ( hex ( session . localPublicKey ) ) ;
130
144
}
0 commit comments