File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 <BApp >
33 <h1 >Connection status: {{ irc.connectionStatus }}</h1 >
44
5- <ChatApp v-if =" irc.isConnected " />
5+ <ChatApp v-if =" irc.isInitialized " />
66 <LoginForm v-else @login =" irc.signIn" />
77 </BApp >
88</template >
Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ export class CustomConnection extends Connection {
1919}
2020
2121const useIrcStore = defineStore ( 'irc' , ( ) => {
22+ /**
23+ * Tracking if the client has started the connection.
24+ * Keeps the chat view visible until client manually signs out.
25+ */
26+ const isInitialized = ref ( false ) ;
2227 const client = shallowRef < Client | null > ( null ) ;
2328 const savedUser = useLocalStorage < Record < 'username' | 'uid' , string > | null > ( 'chat_user' , null ) ;
2429
@@ -97,6 +102,7 @@ const useIrcStore = defineStore('irc', () => {
97102
98103 ircClient . connect ( ) ;
99104 client . value = markRaw ( ircClient ) ;
105+ isInitialized . value = true ;
100106 console . log ( 'IRC Client:' , ircClient ) ;
101107 }
102108
@@ -123,10 +129,12 @@ const useIrcStore = defineStore('irc', () => {
123129
124130 function signOut ( ) {
125131 savedUser . value = null ;
132+ isInitialized . value = false ;
126133 quit ( ) ;
127134 }
128135
129136 return {
137+ isInitialized : readonly ( isInitialized ) ,
130138 client : computed ( ( ) => ( isRegistered . value ? client . value : null ) ) ,
131139 isConnected : computed (
132140 ( ) => isRegistered . value && client . value !== null && connectionStatus . value === 'connected' ,
You can’t perform that action at this time.
0 commit comments