Skip to content

Commit d7e89ae

Browse files
committed
fix: use ref to unhide elements instead of subject
for some reason having hidden=false still hid the element (makes sense, having hidden should hide it
1 parent 602733d commit d7e89ae

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

examples/gauge/Components/InterfaceSample.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
3838
private readonly sqlInputRef = FSComponent.createRef<Input>()
3939
private readonly executeSqlButtonRef = FSComponent.createRef<HTMLButtonElement>()
4040
private readonly outputRef = FSComponent.createRef<HTMLPreElement>()
41+
private readonly loadingRef = FSComponent.createRef<HTMLDivElement>()
42+
private readonly authContainerRef = FSComponent.createRef<HTMLDivElement>()
4143

4244
private readonly navigationDataStatus = Subject.create<NavigationDataStatus | null>(null)
43-
private readonly interfaceInitialized = Subject.create(false)
4445

4546
private cancelSource = CancelToken.source()
4647

@@ -51,18 +52,6 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
5152

5253
this.navigationDataInterface = new NavigraphNavigationDataInterface()
5354

54-
// Populate status when ready
55-
this.navigationDataInterface.onReady(() => {
56-
this.navigationDataInterface
57-
.get_navigation_data_install_status()
58-
.then(status => {
59-
this.navigationDataStatus.set(status)
60-
})
61-
.catch(e => console.error(e))
62-
63-
this.interfaceInitialized.set(true)
64-
})
65-
6655
this.navigationDataInterface.onEvent(NavigraphEventType.DownloadProgress, data => {
6756
switch (data.phase) {
6857
case DownloadProgressPhase.Downloading:
@@ -116,11 +105,11 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
116105
public render(): VNode {
117106
return (
118107
<>
119-
<div class="loading-container" hidden={this.interfaceInitialized}>
108+
<div class="loading-container" ref={this.loadingRef}>
120109
Waiting for navigation data interface to initialize... If building for the first time, this may take a few
121110
minutes
122111
</div>
123-
<div class="auth-container" hidden={this.interfaceInitialized.map(SubscribableMapFunctions.not())}>
112+
<div class="auth-container" ref={this.authContainerRef} style={{ display: "none" }}>
124113
<div class="horizontal">
125114
<div class="vertical">
126115
<h4>Step 1 - Sign in</h4>
@@ -169,6 +158,20 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
169158
public onAfterRender(node: VNode): void {
170159
super.onAfterRender(node)
171160

161+
// Populate status when ready
162+
this.navigationDataInterface.onReady(() => {
163+
this.navigationDataInterface
164+
.get_navigation_data_install_status()
165+
.then(status => {
166+
this.navigationDataStatus.set(status)
167+
})
168+
.catch(e => console.error(e))
169+
170+
// show the auth container
171+
this.authContainerRef.instance.style.display = "block"
172+
this.loadingRef.instance.style.display = "none"
173+
})
174+
172175
this.loginButtonRef.instance.addEventListener("click", () => this.handleClick())
173176
this.downloadButtonRef.instance.addEventListener("click", () => this.handleDownloadClick())
174177

0 commit comments

Comments
 (0)