Skip to content

Commit

Permalink
refactor: migrate ng-cloak effect and remove obsolete ng-strict-di
Browse files Browse the repository at this point in the history
  • Loading branch information
shaman-apprentice committed Oct 31, 2022
1 parent 55e1a3d commit 7bb22a3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/codeCharta.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
<div [style.visibility]="isInitialized ? 'visible' : 'hidden'">
<cc-tool-bar></cc-tool-bar>

<cc-file-extension-bar></cc-file-extension-bar>
Expand Down
11 changes: 11 additions & 0 deletions visualization/app/codeCharta/codeCharta.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@ describe("codeChartaComponent", () => {
expect(mockedStore.dispatch).toHaveBeenCalledWith(setIsLoadingFile(true))
expect(mockedLoadInitialFileService.loadFileOrSample).toHaveBeenCalled()
})

it("should set isInitilized on windows' load event, so the app doesn't flicker on initial page load", () => {
const mockedStore = { dispatch: jest.fn() } as unknown as Store
const mockedLoadInitialFileService = { loadFileOrSample: jest.fn() } as unknown as LoadInitialFileService

const codeChartaComponent = new CodeChartaComponent(mockedStore, mockedLoadInitialFileService)
expect(codeChartaComponent.isInitialized).toBe(false)

window.dispatchEvent(new Event("load"))
expect(codeChartaComponent.isInitialized).toBe(true)
})
})
7 changes: 6 additions & 1 deletion visualization/app/codeCharta/codeCharta.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ import { Store } from "./state/angular-redux/store"
})
export class CodeChartaComponent implements OnInit {
version = packageJson.version
isInitialized = false

constructor(
@Inject(Store) private store: Store,
@Inject(LoadInitialFileService) private loadInitialFileService: LoadInitialFileService
) {}
) {
window.addEventListener("load", () => {
this.isInitialized = true
})
}

async ngOnInit(): Promise<void> {
this.store.dispatch(setIsLoadingFile(true))
Expand Down
2 changes: 1 addition & 1 deletion visualization/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
</head>

<body ng-strict-di>
<body>
<cc-code-charta></cc-code-charta>
</body>
</html>

0 comments on commit 7bb22a3

Please sign in to comment.