@@ -61,9 +61,8 @@ export class UIManager {
6161 constructor ( plugin : SRPlugin ) {
6262 this . plugin = plugin ;
6363 appIcon ( ) ;
64-
65- // Closes all still open tab views when the plugin is loaded, because it causes bugs / empty windows otherwise
6664 this . tabViewManager = new TabViewManager ( this . plugin ) ;
65+ this . tabViewManager . registerAllTabViews ( ) ;
6766
6867 this . sidebarManager = new SidebarManager ( this . plugin ) ;
6968
@@ -78,6 +77,7 @@ export class UIManager {
7877 }
7978
8079 public async onLayoutReady ( ) {
80+ // Closes all still open tab views when the plugin is loaded, because it causes bugs / empty windows otherwise
8181 this . tabViewManager . closeAllTabViews ( ) ;
8282 await this . sidebarManager . activateReviewQueueViewPanel ( ) ;
8383 await this . plugin . dataManager . sync ( ) ;
@@ -110,14 +110,17 @@ export class UIManager {
110110 ) ;
111111
112112 if ( settings . showStatusBar ) {
113- this . statusBarManager . setCount (
114- this . plugin . dataManager . osrCore . remainingDeckTree . getRepItemCount (
115- RepItemState . AnyItem ,
116- true ,
117- ) ,
118- settings . showStatusBar && settings . showCardStatusBarItem ,
119- "card-review" ,
120- ) ;
113+ if ( this . plugin . dataManager . osrCore . remainingDeckTree !== null ) {
114+ this . statusBarManager . setCount (
115+ this . plugin . dataManager . osrCore . remainingDeckTree . getRepItemCount (
116+ RepItemState . AnyItem ,
117+ true ,
118+ ) ,
119+ settings . showStatusBar && settings . showCardStatusBarItem ,
120+ "card-review" ,
121+ ) ;
122+ }
123+
121124 this . statusBarManager . setCount (
122125 this . plugin . dataManager . osrCore . noteReviewQueue . dueNotesCount ,
123126 settings . showStatusBar && settings . showNoteStatusBarItem ,
@@ -169,8 +172,8 @@ export class UIManager {
169172 // Only set focus if it was already in focus, as that is the only case where the tab would be covered by the modal
170173 this . setSRViewInFocus (
171174 ( modal === null || modal === undefined ) &&
172- this . plugin . app . workspace . getActiveViewOfType ( SRTabView ) !== null &&
173- this . plugin . app . workspace . getActiveViewOfType ( SRTabView ) !== undefined ,
175+ this . plugin . app . workspace . getActiveViewOfType ( SRTabView ) !== null &&
176+ this . plugin . app . workspace . getActiveViewOfType ( SRTabView ) !== undefined ,
174177 ) ;
175178 }
176179 }
@@ -241,13 +244,7 @@ export class UIManager {
241244 } ;
242245 const currentWindow = remoteModule ?. getCurrentWindow ?.( ) ;
243246 if ( currentWindow !== null && currentWindow !== undefined ) {
244- return currentWindow as {
245- isMinimized ?: ( ) => boolean ;
246- restore ?: ( ) => void ;
247- show ?: ( ) => void ;
248- focus ?: ( ) => void ;
249- moveTop ?: ( ) => void ;
250- } ;
247+ return currentWindow ;
251248 }
252249 } catch {
253250 // ignore
@@ -259,13 +256,7 @@ export class UIManager {
259256 } ;
260257 const currentWindow = electronModule ?. remote ?. getCurrentWindow ?.( ) ;
261258 if ( currentWindow !== null && currentWindow !== undefined ) {
262- return currentWindow as {
263- isMinimized ?: ( ) => boolean ;
264- restore ?: ( ) => void ;
265- show ?: ( ) => void ;
266- focus ?: ( ) => void ;
267- moveTop ?: ( ) => void ;
268- } ;
259+ return currentWindow ;
269260 }
270261 } catch {
271262 // ignore
@@ -310,9 +301,9 @@ export class UIManager {
310301
311302 const windowObject = activeDocument . defaultView as
312303 | ( Window & {
313- AudioContext ?: typeof AudioContext ;
314- webkitAudioContext ?: typeof AudioContext ;
315- } )
304+ AudioContext ?: typeof AudioContext ;
305+ webkitAudioContext ?: typeof AudioContext ;
306+ } )
316307 | null ;
317308 const AudioContextCtor =
318309 windowObject ?. AudioContext ?? windowObject ?. webkitAudioContext ?? null ;
@@ -369,10 +360,10 @@ export class UIManager {
369360 type ElectronApp = { dock ?: DockApi } ;
370361 const requireFn = (
371362 activeDocument . defaultView as
372- | ( Window & {
373- require ?: ( moduleName : string ) => unknown ;
374- } )
375- | null
363+ | ( Window & {
364+ require ?: ( moduleName : string ) => unknown ;
365+ } )
366+ | null
376367 ) ?. require ;
377368 if ( requireFn === undefined ) {
378369 return ;
0 commit comments