Main-form "Disconnect" option is available if in a reconnection-attempt loop. Remove broken/unused "Show Logs" button.

This commit is contained in:
James Babcock committed 2026-08-24 11:46:40 -07:00
1 parent fa241161e4
commit 1a1416c8f0
4 files changed
+28 -122

No files matched your search

+2 -54
View File
@@ -1,4 +1,4 @@
import { Application, Color, EventData, isAndroid, Observable, Page, ScrollView, TextField } from '@nativescript/core'
import { Application, Color, EventData, isAndroid, Observable, Page, TextField } from '@nativescript/core'
import { MainViewModel } from './main-view-model'
import { dashboardController } from '../g2/dashboard-controller'
@@ -13,9 +13,6 @@ export function navigatingTo(args: EventData) {
type MainPageState = {
model: MainViewModel
isPinnedToBottom: boolean
scrollViews: ScrollView[]
scrollHandler: (args: EventData) => void
propertyChangeHandler: (args: EventData & { propertyName?: string }) => void
orientationHandler: () => void
}
@@ -34,30 +31,11 @@ function cleanupPage(page: Page): void {
setPageState(page, undefined)
return
}
for (const scrollView of state.scrollViews) {
scrollView.off(ScrollView.scrollEvent, state.scrollHandler)
}
state.model.off(Observable.propertyChangeEvent, state.propertyChangeHandler)
Application.off(Application.orientationChangedEvent, state.orientationHandler)
setPageState(page, undefined)
}
function isAtBottom(scrollView: ScrollView): boolean {
return scrollView.scrollableHeight <= 0 || scrollView.verticalOffset >= scrollView.scrollableHeight - 8
}
function scrollToBottom(scrollView: ScrollView): void {
setTimeout(() => {
scrollView.scrollToVerticalOffset(scrollView.scrollableHeight, false)
}, 0)
}
function scrollLogsToBottom(scrollViews: ScrollView[]): void {
for (const scrollView of scrollViews) {
scrollToBottom(scrollView)
}
}
function applySettingsTextFieldContrast(textField: TextField): void {
textField.color = SETTINGS_TEXT_COLOR
textField.backgroundColor = SETTINGS_BACKGROUND_COLOR
@@ -105,64 +83,34 @@ export function loaded(args: EventData) {
// Reopen the apps that were open before the last restart (no-op after the
// first load).
void dashboardController.restoreOpenApps()
const scrollViews = [
page.getViewById<ScrollView>('logScrollView'),
page.getViewById<ScrollView>('logScrollViewLandscape'),
].filter((scrollView): scrollView is ScrollView => !!scrollView)
const settingsTextField = page.getViewById<TextField>('settingsTextField')
model?.refreshLayoutMetrics()
if (settingsTextField) {
applySettingsTextFieldContrast(settingsTextField)
}
if (!model || scrollViews.length === 0) {
if (!model) {
return
}
const state: MainPageState = {
model,
isPinnedToBottom: true,
scrollViews,
scrollHandler: (scrollArgs) => {
state.isPinnedToBottom = isAtBottom(scrollArgs.object as ScrollView)
},
orientationHandler: () => {
setTimeout(() => {
model.refreshLayoutMetrics()
if (state.isPinnedToBottom) {
scrollLogsToBottom(scrollViews)
}
}, 0)
},
propertyChangeHandler: (propertyArgs) => {
if (propertyArgs.propertyName === 'showLog') {
if (model.showLog) {
state.isPinnedToBottom = true
scrollLogsToBottom(scrollViews)
}
return
}
if (propertyArgs.propertyName === 'activeTextSettingId') {
if (model.isTextSettingEditorActive) {
focusTextEditor(page)
}
return
}
if (propertyArgs.propertyName !== 'log') {
return
}
if (state.isPinnedToBottom) {
scrollLogsToBottom(scrollViews)
}
},
}
for (const scrollView of scrollViews) {
scrollView.on(ScrollView.scrollEvent, state.scrollHandler)
}
model.on(Observable.propertyChangeEvent, state.propertyChangeHandler)
Application.on(Application.orientationChangedEvent, state.orientationHandler)
setPageState(page, state)
scrollLogsToBottom(scrollViews)
if (model.isTextSettingEditorActive) {
focusTextEditor(page)
}