fix: refresh deferred imported view on first display#459
Conversation
Refresh the imported timeline when its deferred view is first created. 在延迟创建的已导入视图首次显示时刷新时间线。 Log: 修复已导入界面首次点击不显示的问题 Influence: 已导入视图首次进入和非默认视图懒加载
Reviewer's GuideThis PR fixes a bug where the imported (non-default) timeline view fails to render on first display when created lazily via DeferredView, by explicitly triggering the loader activation and a one-time timeline refresh when the view first becomes visible. Sequence diagram for lazy imported view first display fixsequenceDiagram
actor User
participant GStatus
participant DeferredView
participant Loader
participant HaveImportedView
participant timeline
User->>GStatus: change currentViewType
GStatus-->>DeferredView: currentViewTypeChanged
DeferredView->>DeferredView: loadCurrentView()
alt currentViewType === viewType and !active
DeferredView->>Loader: set active = true
Loader-->>HaveImportedView: create Component
HaveImportedView->>HaveImportedView: Component.onCompleted
HaveImportedView->>Qt: Qt.callLater(function)
Qt-->>HaveImportedView: invoke deferred function
alt visible and !initialContentInitialized
HaveImportedView->>HaveImportedView: flushView()
HaveImportedView->>timeline: refresh()
HaveImportedView->>HaveImportedView: initialContentInitialized = true
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 代码已经非常完善,无需额外修复,保持原样即可。
// DeferredView.qml
Loader {
property int viewType: -1
anchors.fill: parent
asynchronous: false
active: false
function loadCurrentView() {
if (!active && GStatus.currentViewType === viewType)
active = true
}
Connections {
target: GStatus
function onCurrentViewTypeChanged() {
loadCurrentView()
}
}
Component.onCompleted: loadCurrentView()
}
// HaveImportedView.qml
property bool initialContentInitialized: false
function flushView() {
// ...
initialContentInitialized = true
}
Component.onCompleted: {
GStatus.sigFlushHaveImportedView.connect(flushView)
Qt.callLater(function() {
if (visible && !initialContentInitialized)
flushView()
})
} |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In DeferredView.qml, consider deriving
activedirectly fromGStatus.currentViewType === viewType(e.g. via a binding orwhen-style condition) instead of imperatively setting it inloadCurrentView, to avoid potential state drift ifcurrentViewTypechanges in unexpected sequences. - In HaveImportedView.qml, the
initialContentInitializedflag is only set influshView; if the view is hidden and reshown without a flush, you may want to reset this flag appropriately so the Qt.callLater fallback behaves consistently across multiple show/hide cycles.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In DeferredView.qml, consider deriving `active` directly from `GStatus.currentViewType === viewType` (e.g. via a binding or `when`-style condition) instead of imperatively setting it in `loadCurrentView`, to avoid potential state drift if `currentViewType` changes in unexpected sequences.
- In HaveImportedView.qml, the `initialContentInitialized` flag is only set in `flushView`; if the view is hidden and reshown without a flush, you may want to reset this flag appropriately so the Qt.callLater fallback behaves consistently across multiple show/hide cycles.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx, wyu71 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Refresh the imported timeline when its deferred view is first created. 在延迟创建的已导入视图首次显示时刷新时间线。
Log: 修复已导入界面首次点击不显示的问题
Influence: 已导入视图首次进入和非默认视图懒加载
Summary by Sourcery
Ensure deferred thumbnail views activate and refresh correctly when first displayed, so imported timelines render on initial entry.
Bug Fixes:
Enhancements: