-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move navigation logging to `setupLoggingForNavigationInjectable` to prevent cycle of injectables from occurring. Wasn't eventually needed for #6795 but still an improvement. Credit for the implementation goes to @Nokel81 , thanks!
- Loading branch information
1 parent
56197d8
commit aea9232
Showing
2 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/renderer/navigation/setup-logging-for-navigation.injectable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import loggerInjectable from "../../common/logger.injectable"; | ||
import { beforeFrameStartsInjectionToken } from "../before-frame-starts/tokens"; | ||
import observableHistoryInjectable from "./observable-history.injectable"; | ||
|
||
const setupLoggingForNavigationInjectable = getInjectable({ | ||
id: "setup-logging-for-navigation", | ||
instantiate: (di) => ({ | ||
id: "setup-logging-for-navigation", | ||
run: () => { | ||
const logger = di.inject(loggerInjectable); | ||
const observableHistory = di.inject(observableHistoryInjectable); | ||
|
||
observableHistory.listen((location, action) => { | ||
const isClusterView = !process.isMainFrame; | ||
const domain = global.location.href; | ||
|
||
logger.debug(`[NAVIGATION]: ${action}-ing. Current is now:`, { | ||
isClusterView, | ||
domain, | ||
location, | ||
}); | ||
}); | ||
}, | ||
}), | ||
injectionToken: beforeFrameStartsInjectionToken, | ||
}); | ||
|
||
export default setupLoggingForNavigationInjectable; |