mirror of
https://github.com/status-im/status-app.git
synced 2026-08-27 07:01:14 +00:00
A wallet section activation built everything it would ever need before it showed anything: both panels inline, both detail views, every row of two lists synchronously, and a set of subtrees that exist for cases that almost never occur. This reorders that around a single rule - build what is on screen first, build the rest in the incubation controller's metered bites, and build the rest of the rest only when something asks for it. Lists fill preemptibly. A ListView refill is one uninterruptible call inside the window's polish phase, and QQuickItemView creates visible delegates with AsynchronousIfNested - so a list first laid out after its enclosing Loader is already Ready builds every visible row synchronously. On a warm load that was one 34.7ms GUI-thread block against a 3.2ms budget for the assets list, and 8.7-13.5ms of post-content polish across both lists. The assets and accounts delegates become TokenDelegateShell and WalletAccountDelegateShell: an Item carrying the row's geometry and its placeholder tiles, with the real row behind a nested asynchronous Loader. The refill builds shells; the rows incubate afterwards. Row height is the shell's, not the content's. StatusListItem.implicitHeight is Math.max(64, titleArea.height + 16), and both a token row and an account row resolve to that 64px floor, which is what placeholderHeight is. tst_TokenDelegateShell and tst_WalletAccountDelegateShell gate the two staying equal, so a change that makes a row taller fails a test rather than moving contentHeight and the scroll position mid-fill. Each placeholder mirrors the skeleton the per-tab loader showed a moment earlier, so the two loading states read as one handoff. Subtrees built for the exceptional case are latched off. The token row's two warning buttons, the asset detail's four chain-tag warning buttons, its header community tag and its "Minted by" tile were all built unconditionally and merely hidden. Each now sits behind the condition that used to drive `visible`. AssetsDetailsHeader loses its `communityTag` alias, which existed only so callers could reach in and set the tag's contents; it takes communityName/communityImage and builds the tag itself. The two detail views move behind async Loaders keyed on the stack index. The token to show becomes state held in `d` and bound into the view rather than assigned into it, so a second click landing mid-incubation wins without a queue-and-replay; the resets that hung off onVisibleChanged hang off onActiveChanged, which fires on the same edges. Panels build in the order the user sees them. WalletLayout declared both panels as plain object bindings, so activation built LeftTabView and the centre StackView inline and the chrome's two PanelSwapGates could not fire independently - they opened 5ms apart because both panel properties resolve when WalletLayout completes. Each panel now sits behind its own async Loader with its own readiness, the primary one first, and once a skeleton is on screen with no panel switch running the primary panel is built synchronously: the pacing exists to protect section-switch animations, and here the only thing a synchronous block could stutter is the skeleton it replaces. Wrapping the panels in Loaders exposed three geometry defects. A Loader reports its item's implicit size as its own, so the centre StackView's content width propagated into the chrome and pushed the panel past the right edge on a narrow screen; the loaders are bound to the chrome's geometry for the unparented phase, the stack no longer anchors to its loader, and the side inset moves onto the content where it belongs. Panel geometry is coalesced across a rotation. A device rotation walks the window through nine sizes over ~430ms and LayoutItemProxy forwarded every one to the section's panels - a full relayout of a populated subtree each time - and parked a panel at a degenerate box for ~148ms on the portrait/landscape handoff. SectionPanelSlot replaces the panel proxies in both sub-layouts and publishes the box each slot will give its panel, which is also what a section building panels outside the tree needs: the centre slot cannot be guessed, as it is short by the header and footer and narrow by the left column in landscape. Wallet and chat both pre-size their incubating panels to it. Two fixes fall out of that work. BaseProxyPanel looked its SwipeView page up at a fixed implicitIndex, but SwipeView indices close up as pages come and go, so hiding the right panel with no left panel present silently left its page in the view, still swipeable; it now looks the page up by identity. SectionPanelSlot also has to be listed in statusq.qrc - without it the type is absent from the binary's resources, StatusSectionLayout becomes unavailable and the UI process dies precompiling AppMain. Measured on a whale profile, Release, arms alternated between rounds: warm t_first_asset_row 119-159ms -> 51-74ms warm max_stall_ms 31.7-42.6 -> 17.2-26.3ms section ready 631ms -> 207ms visible panel promoted 609ms -> 338ms cold: skeleton shown -> visible 2272ms -> 1836ms objects_total (cold) 4602 -> 3344 (-27%) objects_settled 9569 -> 8297 (-13%) token row QObjects 326 -> 279 panel geometry distinct sizes 24 -> 5 centre, 19 -> 2 left degenerate 0x0 box written 12 occurrences -> 0 Device numbers are only comparable once the app has settled; a run taken while startup backend work is still in flight measured 925ms for a path that measures ~520ms settled. Measurements come from an offscreen storybook wallet bench that is not part of this PR; see branch `feat/storybook-wallet-loader`.
265 lines
10 KiB
QML
265 lines
10 KiB
QML
import QtCore
|
|
import QtQml
|
|
import QtQuick
|
|
|
|
import StatusQ.Core.Theme
|
|
import StatusQ.Layout
|
|
|
|
import AppLayouts.Wallet.panels
|
|
|
|
import utils
|
|
|
|
import shared.stores as SharedStores
|
|
import shared.stores.send
|
|
|
|
import AppLayouts.stores as AppStores
|
|
import AppLayouts.Communities.stores
|
|
import AppLayouts.Wallet.stores as WalletStores
|
|
|
|
import mainui.sectionLoaders
|
|
|
|
Loader {
|
|
id: root
|
|
|
|
// Stores — only what WalletLayout / WalletPrivacyWall consume
|
|
required property AppStores.RootStore rootStore
|
|
required property AppStores.ContactsStore contactsStore
|
|
required property AppStores.FeatureFlagsStore featureFlagsStore
|
|
required property SharedStores.RootStore sharedRootStore
|
|
required property SharedStores.NetworkConnectionStore networkConnectionStore
|
|
required property SharedStores.NetworksStore networksStore
|
|
required property CommunitiesStore communitiesStore
|
|
required property TransactionStore transactionStore
|
|
|
|
// App-shell handlers / shared loaders
|
|
required property HandlersManagerLoader popupHandler
|
|
required property Loader dappsServiceLoader
|
|
required property Loader emojiPopupLoader
|
|
|
|
property bool appMainVisible: false
|
|
property real leftPanelWidthOverride: 0
|
|
|
|
// Back-navigation contract for AppMain's back chain. The chrome is
|
|
// interactive while the section item still incubates, so the loader must
|
|
// answer for it during that phase; once loaded, the item leads.
|
|
readonly property bool canGoBack: root.item?.canGoBack ?? sectionLayout.canGoBack
|
|
function tryGoBack() {
|
|
if (root.item && typeof root.item.tryGoBack === "function")
|
|
return root.item.tryGoBack()
|
|
return sectionLayout.tryGoBack()
|
|
}
|
|
|
|
// Navigation into a specific wallet view may arrive (synchronously, from
|
|
// activity-center/toast redirects) while the section still incubates —
|
|
// queue it and replay once the real layout is up.
|
|
function openDesiredView(leftPanelSelection, rightPanelSelection, data) {
|
|
if (root.item && root.item.openDesiredView) {
|
|
root.item.openDesiredView(leftPanelSelection, rightPanelSelection, data)
|
|
return
|
|
}
|
|
d.pendingViewRequest = ({ left: leftPanelSelection,
|
|
right: rightPanelSelection,
|
|
data: data })
|
|
}
|
|
|
|
asynchronous: true
|
|
|
|
// Once a skeleton is on screen and no panel switch is animating, building
|
|
// the panel the user is waiting for synchronously beats incubating it. The
|
|
// work is the same either way, but the incubation controller's gentle
|
|
// pacing - a 2ms bite every 4ms - spreads it across several hundred ms, and
|
|
// the only thing a block would stutter is the skeleton it replaces.
|
|
readonly property bool panelsMayBuildSync:
|
|
(accountsSkeleton.status === Loader.Ready || centerSkeleton.status === Loader.Ready)
|
|
&& !d.panelSwitchOngoing
|
|
|
|
// The section chrome is owned by the loader: it shows instantly with
|
|
// skeleton panels and swaps in the real panels produced by WalletLayout
|
|
// (LayoutItemProxy retarget) once the section finishes incubating.
|
|
StatusSectionLayout {
|
|
id: sectionLayout
|
|
|
|
anchors.fill: parent
|
|
currentIndex: 1
|
|
|
|
// The privacy wall is a full-page item rendered by the Loader itself
|
|
visible: d.targetUrl !== d.privacyWallUrl
|
|
|
|
backButtonName: root.item?.backButtonName ?? ""
|
|
onBackButtonClicked: root.item?.handleBackButtonClicked()
|
|
subsectionHistory: root.item?.subsectionHistory ?? null
|
|
|
|
leftPanel: leftPanelGate.up ? root.item.leftPanel : accountsSkeleton
|
|
centerPanel: centerPanelGate.up ? root.item.centerPanel : centerSkeleton
|
|
headerBackground: root.item?.headerBackground ?? null
|
|
footer: root.item?.footer ?? null
|
|
|
|
leftPanelWidthOverride: root.leftPanelWidthOverride
|
|
|
|
onPanelSwitchStarted: d.panelSwitchOngoing = true
|
|
onPanelSwitchEnded: d.panelSwitchOngoing = false
|
|
}
|
|
|
|
// One gate per chrome slot: skeleton→panel promotion waits out the
|
|
// chrome's panel-switch animation, or the swap frame stutters it.
|
|
PanelSwapGate {
|
|
id: leftPanelGate
|
|
ready: root.item?.leftPanelReady ?? false
|
|
switchOngoing: d.panelSwitchOngoing
|
|
}
|
|
|
|
PanelSwapGate {
|
|
id: centerPanelGate
|
|
ready: root.item?.centerPanelReady ?? false
|
|
switchOngoing: d.panelSwitchOngoing
|
|
}
|
|
|
|
// Skeleton slot items carry the same page paddings as the real panels
|
|
// (LeftTabView's internal padding, resp. the center StackView's margins).
|
|
// Each lives behind a Loader gated on its slot: an alive invisible skeleton
|
|
// re-evaluates its tile geometry bindings on every resize for the lifetime
|
|
// of the section.
|
|
Loader {
|
|
id: accountsSkeleton
|
|
// the privacy wall is a full-page item: no panels will ever arrive,
|
|
// so don't keep a skeleton alive behind the hidden chrome
|
|
active: !leftPanelGate.up && d.targetUrl !== d.privacyWallUrl
|
|
visible: active
|
|
|
|
sourceComponent: WalletAccountsSkeleton {
|
|
anchors.fill: parent
|
|
anchors.margins: Theme.padding
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: centerSkeleton
|
|
active: !centerPanelGate.up && d.targetUrl !== d.privacyWallUrl
|
|
visible: active
|
|
|
|
sourceComponent: WalletCenterPanelSkeleton {
|
|
anchors.fill: parent
|
|
anchors.topMargin: Theme.padding
|
|
anchors.leftMargin: Theme.xlPadding * 2
|
|
anchors.rightMargin: Theme.xlPadding * 2
|
|
}
|
|
}
|
|
|
|
// Panel index persistence, kept under the same category/key WalletLayout
|
|
// used when it owned the chrome
|
|
Settings {
|
|
category: "WalletLocalSettings_%1".arg(userProfile.pubKey)
|
|
property alias selectedPanelIndex: sectionLayout.currentIndex
|
|
}
|
|
|
|
QtObject {
|
|
id: d
|
|
|
|
property var pendingViewRequest: null
|
|
|
|
readonly property url realUrl: QmlCompiler.walletUrl
|
|
readonly property url privacyWallUrl: QmlCompiler.walletPrivacyWallUrl
|
|
readonly property url targetUrl: rootStore.thirdpartyServicesEnabled ? realUrl : privacyWallUrl
|
|
|
|
// The portrait chrome animates panel switches and brackets them with
|
|
// panelSwitchStarted/Ended: a panel that becomes ready mid-slide
|
|
// keeps its skeleton (via its PanelSwapGate) until the slide ends.
|
|
property bool panelSwitchOngoing: false
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
Qt.callLater(() => QmlCompiler.precompile(d.targetUrl))
|
|
root.loadSection()
|
|
}
|
|
|
|
function loadSection() {
|
|
if (!root.active)
|
|
return
|
|
if (!!root.item && root.source === d.targetUrl)
|
|
return
|
|
|
|
if (d.targetUrl === d.privacyWallUrl) {
|
|
setSource(d.privacyWallUrl, {})
|
|
return
|
|
}
|
|
|
|
setSource(d.realUrl, {
|
|
visible: false,
|
|
objectName: "walletLayoutReal",
|
|
sectionLayout: sectionLayout,
|
|
walletRootStore: WalletStores.RootStore,
|
|
sharedRootStore: Qt.binding(() => root.sharedRootStore),
|
|
store: Qt.binding(() => root.rootStore),
|
|
contactsStore: Qt.binding(() => root.contactsStore),
|
|
communitiesStore: Qt.binding(() => root.communitiesStore),
|
|
transactionStore: Qt.binding(() => root.transactionStore),
|
|
emojiPopup: Qt.binding(() => root.emojiPopupLoader.item),
|
|
networkConnectionStore: Qt.binding(() => root.networkConnectionStore),
|
|
networksStore: Qt.binding(() => root.networksStore),
|
|
appMainVisible: Qt.binding(() => root.appMainVisible),
|
|
swapEnabled: Qt.binding(() => root.featureFlagsStore.swapEnabled),
|
|
buyEnabled: Qt.binding(() => root.featureFlagsStore.buyEnabled),
|
|
dAppsVisible: Qt.binding(() => root.dappsServiceLoader.item
|
|
? root.dappsServiceLoader.item.serviceAvailableToCurrentAddress
|
|
: false),
|
|
dAppsEnabled: Qt.binding(() => root.dappsServiceLoader.item
|
|
? root.dappsServiceLoader.item.isServiceOnline
|
|
: false),
|
|
dAppsModel: Qt.binding(() => root.dappsServiceLoader.item
|
|
? root.dappsServiceLoader.item.dappsModel
|
|
: null),
|
|
isKeycardEnabled: Qt.binding(() => root.featureFlagsStore.keycardEnabled),
|
|
buildPanelsSync: Qt.binding(() => root.panelsMayBuildSync),
|
|
})
|
|
}
|
|
|
|
onActiveChanged: {
|
|
if (!root.active) {
|
|
WalletStores.RootStore.showSavedAddresses = false
|
|
WalletStores.RootStore.showFollowingAddresses = false
|
|
WalletStores.RootStore.selectedAddress = ""
|
|
}
|
|
loadSection()
|
|
}
|
|
onLoaded: {
|
|
if (root.item.resetView)
|
|
root.item.resetView()
|
|
root.item.visible = true
|
|
if (d.pendingViewRequest) {
|
|
const request = d.pendingViewRequest
|
|
d.pendingViewRequest = null
|
|
if (root.item.openDesiredView)
|
|
root.item.openDesiredView(request.left, request.right, request.data)
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: root.rootStore
|
|
function onThirdpartyServicesEnabledChanged() { root.loadSection() }
|
|
}
|
|
|
|
Connections {
|
|
target: root.item
|
|
ignoreUnknownSignals: true
|
|
|
|
function onDappConnectRequested() {
|
|
root.dappsServiceLoader.dappConnectRequested()
|
|
}
|
|
function onDappDisconnectRequested(dappUrl) {
|
|
root.dappsServiceLoader.dappDisconnectRequested(dappUrl)
|
|
}
|
|
function onSendTokenRequested(senderAddress, groupKey, tokenType) {
|
|
root.popupHandler.sendToken(senderAddress, groupKey, tokenType)
|
|
}
|
|
function onOpenSwapModalRequested(swapFormData) {
|
|
root.popupHandler.launchSwapSpecific(swapFormData)
|
|
}
|
|
function onOpenThirdpartyServicesInfoPopupRequested() {
|
|
root.popupHandler.openThirdpartyServicesPopup()
|
|
}
|
|
function onOpenDiscussPageRequested() {
|
|
Global.requestOpenLink(Constants.statusDiscussPageUrl)
|
|
}
|
|
}
|
|
}
|