fix(Communities): ensure profile popup is hydrated with correct data

The `communityProfilePopup` relies on the currently `activeCommunity` to
get its data. Unfortunately, once read, even when `chatsModel.setActiveCommunity()`
is called which triggers `activeCommunityChanged`, the data in the popup
won't be updated. The next time one would open a community profile page,
it'd have the data that was previously received from the model.

This commit ensures that the popup is hydrated with the most recent data
by explicitly updating its properties right before it's opened.
This commit is contained in:
Pascal Precht 2021-03-09 14:25:00 +01:00 committed by Iuri Matias
parent 51c8d86ccc
commit 2e710715bc
2 changed files with 16 additions and 2 deletions

View File

@ -56,7 +56,14 @@ Button {
visible: enabled visible: enabled
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.fill: parent anchors.fill: parent
onPressed: communityProfilePopup.open(); onPressed: {
communityProfilePopup.communityId = chatsModel.communities.activeCommunity.id;
communityProfilePopup.name = chatsModel.communities.activeCommunity.name;
communityProfilePopup.description = chatsModel.communities.activeCommunity.description;
communityProfilePopup.access = chatsModel.communities.activeCommunity.access;
communityProfilePopup.nbMembers = chatsModel.communities.activeCommunity.nbMembers;
communityProfilePopup.open();
}
hoverEnabled: true hoverEnabled: true
onExited: { onExited: {
btnBackground.color = Style.current.transparent btnBackground.color = Style.current.transparent

View File

@ -86,6 +86,13 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: Style.current.padding anchors.bottomMargin: Style.current.padding
onClicked: communityProfilePopup.open() onClicked: {
communityProfilePopup.communityId = chatsModel.communities.activeCommunity.id;
communityProfilePopup.name = chatsModel.communities.activeCommunity.name;
communityProfilePopup.description = chatsModel.communities.activeCommunity.description;
communityProfilePopup.access = chatsModel.communities.activeCommunity.access;
communityProfilePopup.nbMembers = chatsModel.communities.activeCommunity.nbMembers;
communityProfilePopup.open()
}
} }
} }