chore(AppMain): use Loaders more aggressively, unloading any previous unused section
- another bit on the road to reduce startup time and be more conservative towards RAM usage - remove more imperative JS code - only preload/prepare the currently active community, not all of them on startup Fixes #8782
This commit is contained in:
parent
5a69cde2bc
commit
ab96c17fb2
|
@ -67,11 +67,11 @@ Item {
|
||||||
keycardPopup.active = false
|
keycardPopup.active = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMailserverNotWorking() {
|
onMailserverNotWorking: {
|
||||||
Global.openPopup(mailserverNotWorkingPopupComponent)
|
Global.openPopup(mailserverNotWorkingPopupComponent)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onActiveSectionChanged() {
|
onActiveSectionChanged: {
|
||||||
createChatView.opened = false
|
createChatView.opened = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,8 @@ Item {
|
||||||
Connections {
|
Connections {
|
||||||
target: Global
|
target: Global
|
||||||
onOpenLinkInBrowser: {
|
onOpenLinkInBrowser: {
|
||||||
if (!browserLayoutContainer.active)
|
changeAppSectionBySectionId(Constants.appSection.browser)
|
||||||
browserLayoutContainer.active = true;
|
Qt.callLater(() => browserLayoutContainer.item.openUrlInNewTab(link));
|
||||||
browserLayoutContainer.item.openUrlInNewTab(link);
|
|
||||||
}
|
}
|
||||||
onOpenChooseBrowserPopup: {
|
onOpenChooseBrowserPopup: {
|
||||||
Global.openPopup(chooseBrowserPopupComponent, {link: link});
|
Global.openPopup(chooseBrowserPopupComponent, {link: link});
|
||||||
|
@ -402,17 +401,17 @@ Item {
|
||||||
changeAppSectionBySectionId(model.id)
|
changeAppSectionBySectionId(model.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
popupMenu: StatusMenu {
|
popupMenu: Component {
|
||||||
|
StatusMenu {
|
||||||
id: communityContextMenu
|
id: communityContextMenu
|
||||||
|
|
||||||
property var chatCommunitySectionModule
|
property var chatCommunitySectionModule
|
||||||
|
|
||||||
openHandler: function () {
|
openHandler: function () {
|
||||||
// // we cannot return QVariant if we pass another parameter in a function call
|
// we cannot return QVariant if we pass another parameter in a function call
|
||||||
// // that's why we're using it this way
|
// that's why we're using it this way
|
||||||
appMain.rootStore.mainModuleInst.prepareCommunitySectionModuleForCommunityId(model.id)
|
appMain.rootStore.mainModuleInst.prepareCommunitySectionModuleForCommunityId(model.id)
|
||||||
communityContextMenu.chatCommunitySectionModule = appMain.rootStore.mainModuleInst.getCommunitySectionModule()
|
communityContextMenu.chatCommunitySectionModule = appMain.rootStore.mainModuleInst.getCommunitySectionModule()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusAction {
|
StatusAction {
|
||||||
|
@ -446,6 +445,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
regularItemsModel: SortFilterProxyModel {
|
regularItemsModel: SortFilterProxyModel {
|
||||||
sourceModel: appMain.rootStore.mainModuleInst.sectionsModel
|
sourceModel: appMain.rootStore.mainModuleInst.sectionsModel
|
||||||
|
@ -803,20 +803,16 @@ Item {
|
||||||
if (activeSectionType === Constants.appSection.chat)
|
if (activeSectionType === Constants.appSection.chat)
|
||||||
return Constants.appViewStackIndex.chat
|
return Constants.appViewStackIndex.chat
|
||||||
if (activeSectionType === Constants.appSection.community) {
|
if (activeSectionType === Constants.appSection.community) {
|
||||||
|
for (let i = this.children.length - 1; i >=0; i--) {
|
||||||
for(let i = this.children.length - 1; i >=0; i--)
|
|
||||||
{
|
|
||||||
var obj = this.children[i]
|
var obj = this.children[i]
|
||||||
if (obj && obj.sectionId && obj.sectionId === appMain.rootStore.mainModuleInst.activeSection.id)
|
if (obj && obj.sectionId && obj.sectionId === appMain.rootStore.mainModuleInst.activeSection.id) {
|
||||||
{
|
|
||||||
obj.active = true
|
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should never be here, correct index must be returned from the for loop above
|
// Should never be here, correct index must be returned from the for loop above
|
||||||
console.error("Wrong section type: ", appMain.rootStore.mainModuleInst.activeSection.sectionType,
|
console.error("Wrong section type:", appMain.rootStore.mainModuleInst.activeSection.sectionType,
|
||||||
" or section id: ", appMain.rootStore.mainModuleInst.activeSection.id)
|
"or section id: ", appMain.rootStore.mainModuleInst.activeSection.id)
|
||||||
return Constants.appViewStackIndex.community
|
return Constants.appViewStackIndex.community
|
||||||
}
|
}
|
||||||
if (activeSectionType === Constants.appSection.communitiesPortal)
|
if (activeSectionType === Constants.appSection.communitiesPortal)
|
||||||
|
@ -834,35 +830,6 @@ Item {
|
||||||
console.error("AppMain: Unknown section type")
|
console.error("AppMain: Unknown section type")
|
||||||
}
|
}
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
var obj = this.children[currentIndex]
|
|
||||||
if (!obj)
|
|
||||||
return
|
|
||||||
|
|
||||||
createChatView.opened = false
|
|
||||||
|
|
||||||
if (obj === browserLayoutContainer && browserLayoutContainer.active == false) {
|
|
||||||
browserLayoutContainer.active = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj === walletLayoutContainer && !walletLayoutContainer.active) {
|
|
||||||
walletLayoutContainer.active = true
|
|
||||||
walletLayoutContainer.item.showSigningPhrasePopup()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj === profileLayoutContainer && !profileLayoutContainer.active) {
|
|
||||||
profileLayoutContainer.active = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj === nodeLayoutContainer && !nodeLayoutContainer.active) {
|
|
||||||
nodeLayoutContainer.active = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj.onActivated && typeof obj.onActivated === "function") {
|
|
||||||
this.children[currentIndex].onActivated()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// If we ever change stack layout component order we need to updade
|
// If we ever change stack layout component order we need to updade
|
||||||
// Constants.appViewStackIndex accordingly
|
// Constants.appViewStackIndex accordingly
|
||||||
|
@ -903,8 +870,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: walletLayoutContainer
|
active: appView.currentIndex === Constants.appViewStackIndex.wallet
|
||||||
active: false
|
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
sourceComponent: WalletLayout {
|
sourceComponent: WalletLayout {
|
||||||
store: appMain.rootStore
|
store: appMain.rootStore
|
||||||
|
@ -912,11 +878,12 @@ Item {
|
||||||
emojiPopup: statusEmojiPopup
|
emojiPopup: statusEmojiPopup
|
||||||
sendModalPopup: sendModal
|
sendModalPopup: sendModal
|
||||||
}
|
}
|
||||||
|
onLoaded: item.showSigningPhrasePopup()
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: browserLayoutContainer
|
id: browserLayoutContainer
|
||||||
active: false
|
active: appView.currentIndex === Constants.appViewStackIndex.browser
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
sourceComponent: BrowserLayout {
|
sourceComponent: BrowserLayout {
|
||||||
globalStore: appMain.rootStore
|
globalStore: appMain.rootStore
|
||||||
|
@ -934,8 +901,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: profileLayoutContainer
|
active: appView.currentIndex === Constants.appViewStackIndex.profile
|
||||||
active: false
|
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
sourceComponent: ProfileLayout {
|
sourceComponent: ProfileLayout {
|
||||||
store: appMain.rootStore.profileSectionStore
|
store: appMain.rootStore.profileSectionStore
|
||||||
|
@ -946,8 +912,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: nodeLayoutContainer
|
active: appView.currentIndex === Constants.appViewStackIndex.node
|
||||||
active: false
|
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
sourceComponent: NodeLayout {}
|
sourceComponent: NodeLayout {}
|
||||||
}
|
}
|
||||||
|
@ -961,8 +926,8 @@ Item {
|
||||||
roleValue: Constants.appSection.community
|
roleValue: Constants.appSection.community
|
||||||
|
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
property string sectionId: model.id
|
readonly property string sectionId: model.id
|
||||||
active: false
|
active: sectionId === appMain.rootStore.mainModuleInst.activeSection.id
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
|
Loading…
Reference in New Issue