mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-03 02:06:19 +00:00
50132c5a0e
* refactor(contacts): refactor 5 contact models into one and filter in QML Fixes #16549 Refactors the 5 types of contact models (all, mutuals, banned, received and sent) into only the `allContacts` and use an Adaptor on the QML side to filter into the needed models. This cleans the Nim side a lot and makes applying updates to the contacts' model way simpler. * chore(contacts): remove useless and duplicated contact properties OptionalName and isSyncing were never used. DefaultDisplayName was not really used and is actually a duplication of preferredDisplayName, so I replaced the limited usages of DefaultDisplayName by preferredDisplayName * refactor(contacts): improve updates by not removing and re-adding We used to update contact items by removing them from the models and re-adding them. This is highly inefficient. Instead, the proper way is to update only the values that changed. * user_model: onItemChanged signal removed * user_model: sorting by online status no longer needed on nim side * Chat/RootStore: contactsModel property removed * ContactsStore encapsulation improved * ContactsStore: contacts model adaptor moved outside store --------- Co-authored-by: Michał Cieślak <michalcieslak@status.im>
79 lines
3.3 KiB
QML
79 lines
3.3 KiB
QML
import QtQml 2.15
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
import utils 1.0
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
QObject {
|
|
id: root
|
|
|
|
/**
|
|
Expected model structure:
|
|
|
|
pubKey [string] - unique identifier of a member, e.g "0x3234235"
|
|
displayName [string] - member's chosen name
|
|
preferredDisplayName [string] - calculated member name according to priorities (eg: nickname has higher priority)
|
|
ensName [string] - member's ENS name
|
|
isEnsVerified [bool] - whether the ENS name was verified on chain
|
|
localNickname [string] - local nickname set by the current user
|
|
alias [string] - generated 3 word name
|
|
icon [string] - thumbnail image of the user
|
|
colorId [string] - generated color ID for the user's profile
|
|
colorHash [string] - generated color hash for the user's profile
|
|
onlineStatus [int] - the online status of the member
|
|
isContact [bool] - whether the user is a mutual contact or not
|
|
isVerified [bool] - wheter the user has been marked as verified or not
|
|
isUntrustworthy [bool] - wheter the user has been marked as untrustworthy or not
|
|
isBlocked [bool] - whether the user has been blocked or not
|
|
contactRequest [int] - state of the contact request that was sent
|
|
isCurrentUser [bool] - whether the contact is actually ourselves
|
|
lastUpdated [int64] - clock of when last the contact was updated
|
|
lastUpdatedLocally [int64] - clock of when last the contact was updated locally
|
|
bio [string] - contacts's chosen bio text
|
|
thumbnailImage [string] - local url of the user's thumbnail image
|
|
largeImage [string] - local url of the user's large image
|
|
isContactRequestReceived [bool] - whether we received a contact request from that user
|
|
isContactRequestSent [bool] - whether we send a contact request to that user
|
|
isRemoved [bool] - whether we removed that contact
|
|
trustStatus [int] - the trust status of the user as an enum
|
|
**/
|
|
property var allContacts
|
|
|
|
readonly property var mutualContacts: SortFilterProxyModel {
|
|
sourceModel: root.allContacts ?? null
|
|
|
|
filters: ValueFilter {
|
|
roleName: "isContact"
|
|
value: true
|
|
}
|
|
}
|
|
|
|
readonly property var blockedContacts: SortFilterProxyModel {
|
|
sourceModel: root.allContacts ?? null
|
|
|
|
filters: ValueFilter {
|
|
roleName: "isBlocked"
|
|
value: true
|
|
}
|
|
}
|
|
|
|
readonly property var pendingReceivedRequestContacts: SortFilterProxyModel {
|
|
sourceModel: root.allContacts ?? null
|
|
|
|
filters: ValueFilter {
|
|
roleName: "contactRequest"
|
|
value: Constants.ContactRequestState.Received
|
|
}
|
|
}
|
|
|
|
readonly property var pendingSentRequestContacts: SortFilterProxyModel {
|
|
sourceModel: root.allContacts ?? null
|
|
|
|
filters: ValueFilter {
|
|
roleName: "contactRequest"
|
|
value: Constants.ContactRequestState.Sent
|
|
}
|
|
}
|
|
}
|