Skip to content

Commit

Permalink
fix(abc:reuse-tab): fix can't cache when component is not used (#1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Mar 11, 2024
1 parent 86a6e3c commit 4cb939b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/abc/reuse-tab/reuse-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ export class ReuseTabService implements OnDestroy {
*/
store(_snapshot: ActivatedRouteSnapshot, _handle: NzSafeAny): void {
const url = this.getUrl(_snapshot);
const idx = this.index(url);
if (idx === -1) return;

if (_handle != null) {
this.saveCache(_snapshot, _handle);
Expand All @@ -492,9 +490,11 @@ export class ReuseTabService implements OnDestroy {
_snapshot,
_handle
};

const idx = this.index(url);
// Current handler is null when activate routes
// For better reliability, we need to wait for the component to be attached before call _onReuseInit
const cahcedComponentRef = list[idx]._handle?.componentRef;
const cahcedComponentRef = list[idx]?._handle?.componentRef;
if (_handle == null && cahcedComponentRef != null) {
timer(100)
.pipe(take(1))
Expand Down

0 comments on commit 4cb939b

Please sign in to comment.