Skip to content

Commit

Permalink
fix: remove history tracking (onecx#368)
Browse files Browse the repository at this point in the history
* fix: remove history tracking

* fix: boolean flags

* misc: libs update
  • Loading branch information
BenjaminPabst authored Oct 23, 2024
1 parent 54ec9b2 commit 596495f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 68 deletions.
99 changes: 55 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
"@angular/router": "^18.2.6",
"@ngx-translate/core": "^15.0.0",
"@nx/angular": "19.8.2",
"@onecx/accelerator": "^5.19.2",
"@onecx/angular-accelerator": "^5.19.2",
"@onecx/angular-auth": "^5.19.2",
"@onecx/angular-integration-interface": "^5.19.2",
"@onecx/angular-remote-components": "^5.19.2",
"@onecx/angular-webcomponents": "^5.19.2",
"@onecx/integration-interface": "^5.19.2",
"@onecx/keycloak-auth": "^5.19.2",
"@onecx/portal-integration-angular": "^5.19.2",
"@onecx/portal-layout-styles": "^5.19.2",
"@onecx/shell-core": "^5.19.2",
"@onecx/accelerator": "^5.20.0",
"@onecx/angular-accelerator": "^5.20.0",
"@onecx/angular-auth": "^5.20.0",
"@onecx/angular-integration-interface": "^5.20.0",
"@onecx/angular-remote-components": "^5.20.0",
"@onecx/angular-webcomponents": "^5.20.0",
"@onecx/integration-interface": "^5.20.0",
"@onecx/keycloak-auth": "^5.20.0",
"@onecx/portal-integration-angular": "^5.20.0",
"@onecx/portal-layout-styles": "^5.20.0",
"@onecx/shell-core": "^5.20.0",
"@openapitools/openapi-generator-cli": "^2.13.9",
"keycloak-angular": "^16.0.1",
"keycloak-js": "^25.0.6",
Expand Down
20 changes: 7 additions & 13 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function configurationServiceInitializer(configurationService: Configurat
return () => configurationService.init()
}

let history: string[] = []
let isFirst = true
let isInitialPageLoad = true
const pushState = window.history.pushState
window.history.pushState = (data: any, unused: string, url?: string) => {
Expand All @@ -161,13 +161,12 @@ window.history.pushState = (data: any, unused: string, url?: string) => {
type: 'navigated',
payload: {
url,
isFirst: history.length === 0,
history
isFirst
} satisfies NavigatedEventPayload
})

if (!isInitialPageLoad) {
history.push(url ?? '')
history = history.slice(-100)
isFirst = false
}
isInitialPageLoad = false
}
Expand All @@ -179,17 +178,12 @@ window.history.replaceState = (data: any, unused: string, url?: string) => {
type: 'navigated',
payload: {
url,
isFirst: history.length === 0,
history
isFirst: isFirst
} satisfies NavigatedEventPayload
})

if (!isInitialPageLoad) {
if (history.length === 0) {
history.push(url ?? '')
} else {
const lastIndex = history.length - 1
history[lastIndex] = url ?? ''
}
isFirst = false
}
isInitialPageLoad = false
}
Expand Down

0 comments on commit 596495f

Please sign in to comment.