@@ -78,7 +78,27 @@ const TopLevelNavigator = () => {
78
78
const { createStorage } = useDb ( )
79
79
const { prompt } = useDialog ( )
80
80
const { setGeneralStatus } = useGeneralStatus ( )
81
- const { signOut } = useBoostHub ( )
81
+ const { requestSignOut } = useBoostHub ( )
82
+
83
+ const signOut = useCallback ( async ( ) => {
84
+ if (
85
+ routeParams . name === 'boosthub.teams.show' ||
86
+ routeParams . name === 'boosthub.teams.create'
87
+ ) {
88
+ push ( '/app/boosthub/login' )
89
+ }
90
+ setPreferences ( {
91
+ 'boosthub.user' : null ,
92
+ } )
93
+ setGeneralStatus ( {
94
+ boostHubTeams : [ ] ,
95
+ } )
96
+ try {
97
+ await requestSignOut ( )
98
+ } catch ( error ) {
99
+ console . warn ( 'Failed to send signing out request' , error )
100
+ }
101
+ } , [ routeParams . name , setPreferences , setGeneralStatus , requestSignOut , push ] )
82
102
83
103
const openSideNavContextMenu = useCallback (
84
104
( event : React . MouseEvent ) => {
@@ -126,26 +146,8 @@ const TopLevelNavigator = () => {
126
146
}
127
147
: {
128
148
type : 'normal' ,
129
- label : 'Log out Boost Hub' ,
130
- click : async ( ) => {
131
- if (
132
- routeParams . name === 'boosthub.teams.show' ||
133
- routeParams . name === 'boosthub.teams.create'
134
- ) {
135
- push ( '/app/boosthub/login' )
136
- }
137
- setPreferences ( {
138
- 'boosthub.user' : null ,
139
- } )
140
- setGeneralStatus ( {
141
- boostHubTeams : [ ] ,
142
- } )
143
- try {
144
- await signOut ( )
145
- } catch ( error ) {
146
- console . warn ( 'Failed to send signing out request' , error )
147
- }
148
- } ,
149
+ label : 'Sign Out Boost Hub' ,
150
+ click : signOut ,
149
151
} ,
150
152
{
151
153
type : 'separator' ,
@@ -162,16 +164,7 @@ const TopLevelNavigator = () => {
162
164
] ,
163
165
} )
164
166
} ,
165
- [
166
- boostHubUserInfo ,
167
- prompt ,
168
- createStorage ,
169
- signOut ,
170
- push ,
171
- setPreferences ,
172
- setGeneralStatus ,
173
- routeParams . name ,
174
- ]
167
+ [ boostHubUserInfo , prompt , createStorage , push , setPreferences , signOut ]
175
168
)
176
169
177
170
const openNewStorageContextMenu : MouseEventHandler < HTMLButtonElement > = useCallback (
@@ -180,26 +173,48 @@ const TopLevelNavigator = () => {
180
173
openContextMenu ( {
181
174
menuItems : [
182
175
{ label : 'Create a Note Storage' , click : goToStorageCreatePage } ,
183
- boostHubUserInfo == null
184
- ? {
185
- label : isChecked ( featureBoostHubSignIn )
186
- ? 'Create a Team Account'
187
- : 'Create a Team Account (New)' ,
188
- click : ( ) => {
189
- checkFeature ( featureBoostHubSignIn )
190
- push ( '/app/boosthub/login' )
176
+ ...( boostHubUserInfo == null
177
+ ? ( [
178
+ {
179
+ type : 'separator' ,
191
180
} ,
192
- }
193
- : {
194
- label : 'Create a Team' ,
195
- click : ( ) => {
196
- push ( '/app/boosthub/teams' )
181
+ {
182
+ label : isChecked ( featureBoostHubSignIn )
183
+ ? 'Create a Team Account'
184
+ : 'Create a Team Account (New)' ,
185
+ click : ( ) => {
186
+ checkFeature ( featureBoostHubSignIn )
187
+ push ( '/app/boosthub/login' )
188
+ } ,
197
189
} ,
198
- } ,
190
+ ] as MenuItemConstructorOptions [ ] )
191
+ : ( [
192
+ {
193
+ label : 'Create a Team' ,
194
+ click : ( ) => {
195
+ push ( '/app/boosthub/teams' )
196
+ } ,
197
+ } ,
198
+ {
199
+ type : 'separator' ,
200
+ } ,
201
+ {
202
+ type : 'normal' ,
203
+ label : 'Sign Out Boost Hub' ,
204
+ click : signOut ,
205
+ } ,
206
+ ] as MenuItemConstructorOptions [ ] ) ) ,
199
207
] ,
200
208
} )
201
209
} ,
202
- [ goToStorageCreatePage , isChecked , checkFeature , push , boostHubUserInfo ]
210
+ [
211
+ goToStorageCreatePage ,
212
+ isChecked ,
213
+ checkFeature ,
214
+ push ,
215
+ boostHubUserInfo ,
216
+ signOut ,
217
+ ]
203
218
)
204
219
205
220
return (
0 commit comments