fix(CommunityService): ensure communitySettings aren't mistakenly

overwritten

When communities are edited, status-go sends a signal with the community
description, to ensure the network is updated to the latest changes.

However, that community description doesn't include `communitySettings`.
When we then compose the `CommunityDto` object from that signal, it will have
a default certain settings to `false` which might actually be `true`.

The result is that data in memory is incorrect.

To ensure we don't run into this issue, we check whether the attached
settings have an id, if they don't, we know the settings do not
originate from the signal data, meaning we can use the settings we
already have.
This commit is contained in:
Pascal Precht 2022-05-11 14:22:47 +02:00 committed by Iuri Matias
parent c55c93ed59
commit d70a23cb9a
1 changed files with 7 additions and 0 deletions

View File

@ -204,6 +204,13 @@ QtObject:
let prev_community = self.joinedCommunities[community.id] let prev_community = self.joinedCommunities[community.id]
# If there's settings without `id` it means the original
# signal didn't include actual communitySettings, hence we
# assign the settings we already have, otherwise we risk our
# settings to be overridden with wrong defaults.
if community.settings.id == "":
community.settings = prev_community.settings
# category was added # category was added
if(community.categories.len > prev_community.categories.len): if(community.categories.len > prev_community.categories.len):
for category in community.categories: for category in community.categories: