@@ -101,7 +101,7 @@ class TbContext implements PopEntry {
101101 }) async {
102102 log.debug ('TbContext:reinit()' );
103103
104- _handleRootState = false ;
104+ _handleRootState = true ;
105105
106106 tbClient = ThingsboardClient (
107107 endpoint,
@@ -142,7 +142,7 @@ class TbContext implements PopEntry {
142142
143143 void onError (ThingsboardError tbError) {
144144 log.error ('onError' , tbError, tbError.getStackTrace ());
145- _overlayService.showErrorNotification ((_) => tbError.message! );
145+ _overlayService.showErrorNotification ((_) => tbError.message! );
146146 }
147147
148148 void onLoadStarted () {
@@ -245,7 +245,13 @@ class TbContext implements PopEntry {
245245
246246 if (Utils .isConnectionError (e)) {
247247 final res = await _overlayService.showAlertDialog (
248- content: (context) => DialogContent (title: S .of (context).connectionError, message: S .of (context).failedToConnectToServer, ok: S .of (context).retry,),);
248+ content:
249+ (context) => DialogContent (
250+ title: S .of (context).connectionError,
251+ message: S .of (context).failedToConnectToServer,
252+ ok: S .of (context).retry,
253+ ),
254+ );
249255 if (res == true ) {
250256 _overlayService.hideNotification ();
251257 onUserLoaded ();
@@ -276,7 +282,10 @@ class TbContext implements PopEntry {
276282 }
277283
278284 _appLinkStreamSubscription ?? = appLinks.uriLinkStream.listen (
279- (link) {
285+ (Uri ? link) {
286+ if (link == null ) {
287+ return ;
288+ }
280289 thingsboardAppRouter.navigateByAppLink (link.toString ());
281290 },
282291 onError: (err) {
@@ -303,54 +312,54 @@ class TbContext implements PopEntry {
303312 _appLinkStreamSubscription = null ;
304313 }
305314
306- Future <void > updateRouteState () async {
315+ Future <void > updateRouteState () async {
307316 log.debug (
308317 'TbContext:updateRouteState() ${currentState != null && currentState !.mounted }' ,
309318 );
310- if (currentState != null && currentState! .mounted) {
311- if (tbClient.isAuthenticated () && ! tbClient.isPreVerificationToken ()) {
312- final defaultDashboardId = _defaultDashboardId ();
313- if (defaultDashboardId != null ) {
314- final bool fullscreen = _userForceFullscreen ();
315- if (! fullscreen) {
316- await thingsboardAppRouter.navigateToDashboard (
317- defaultDashboardId,
318- animate: false ,
319- );
320- thingsboardAppRouter.navigateTo (
321- '/main' ,
322- replace: true ,
323- closeDashboard: false ,
324- clearStack: true ,
325- transition: TransitionType .none,
326- );
327- } else {
328- thingsboardAppRouter.navigateTo (
329- '/fullscreenDashboard/$defaultDashboardId ' ,
330- replace: true ,
331- clearStack: true ,
332- transition: TransitionType .fadeIn,
333- );
334- }
335- } else {
336- thingsboardAppRouter.navigateTo (
337- '/main' ,
338- replace: true ,
339- clearStack: true ,
340- transition: TransitionType .fadeIn,
341- transitionDuration: const Duration (milliseconds: 750 ),
342- );
343- }
344- } else {
345- thingsboardAppRouter.navigateTo (
346- '/login' ,
347- replace: true ,
348- clearStack: true ,
349- transition: TransitionType .fadeIn,
350- transitionDuration: const Duration (milliseconds: 750 ),
351- );
352- }
319+
320+ if (! tbClient.isAuthenticated () || tbClient.isPreVerificationToken ()) {
321+ thingsboardAppRouter.navigateTo (
322+ '/login' ,
323+ replace: true ,
324+ clearStack: true ,
325+ transition: TransitionType .fadeIn,
326+ transitionDuration: const Duration (milliseconds: 750 ),
327+ );
328+ return ;
353329 }
330+
331+ final defaultDashboardId = _defaultDashboardId ();
332+ if (defaultDashboardId == null ) {
333+ thingsboardAppRouter.navigateTo (
334+ '/main' ,
335+ replace: true ,
336+ clearStack: true ,
337+ transition: TransitionType .fadeIn,
338+ transitionDuration: const Duration (milliseconds: 750 ),
339+ );
340+ return ;
341+ }
342+ final bool fullscreen = _userForceFullscreen ();
343+ if (fullscreen) {
344+ thingsboardAppRouter.navigateTo (
345+ '/fullscreenDashboard/$defaultDashboardId ' ,
346+ replace: true ,
347+ clearStack: true ,
348+ transition: TransitionType .fadeIn,
349+ );
350+ return ;
351+ }
352+ await thingsboardAppRouter.navigateToDashboard (
353+ defaultDashboardId,
354+ animate: false ,
355+ );
356+ thingsboardAppRouter.navigateTo (
357+ '/main' ,
358+ replace: true ,
359+ closeDashboard: false ,
360+ clearStack: true ,
361+ transition: TransitionType .none,
362+ );
354363 }
355364
356365 String ? _defaultDashboardId () {
0 commit comments