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
This commit is contained in:
Jonathan Rainville 2024-10-30 12:17:15 -04:00 committed by Michał Cieślak
parent 9315dd26e0
commit f09acd1a70
11 changed files with 17 additions and 101 deletions

View File

@ -331,7 +331,7 @@ method toggleReactionFromOthers*(self: Module, messageId: string, emojiId: int,
if(item.shouldAddReaction(emojiIdAsEnum, reactionFrom)):
let userWhoAddedThisReaction = self.controller.getContactById(reactionFrom)
self.view.pinnedModel().addReaction(messageId, emojiIdAsEnum, didIReactWithThisEmoji = false,
userWhoAddedThisReaction.id, userWhoAddedThisReaction.userDefaultDisplayName(), reactionId)
userWhoAddedThisReaction.id, userWhoAddedThisReaction.userDefaultDisplayName(), reactionId)
else:
self.view.pinnedModel().removeReaction(messageId, emojiIdAsEnum, reactionId, didIRemoveThisReaction = false)
else:

View File

@ -1188,8 +1188,6 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string, getVerifi
let jsonObj = %* {
# contact details props
"defaultDisplayName": contactDetails.defaultDisplayName,
"optionalName": contactDetails.optionalName,
"icon": contactDetails.icon,
"isCurrentUser": contactDetails.isCurrentUser,
"colorId": contactDetails.colorId,
@ -1210,7 +1208,6 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string, getVerifi
"isBlocked": contactDetails.dto.isBlocked,
"isContactRequestReceived": contactDetails.dto.isContactRequestReceived,
"isContactRequestSent": contactDetails.dto.isContactRequestSent,
"isSyncing": contactDetails.dto.isSyncing,
"removed": contactDetails.dto.removed,
"trustStatus": contactDetails.dto.trustStatus.int,
"contactRequestState": contactDetails.dto.contactRequestState.int,

View File

@ -87,8 +87,6 @@ proc createItemFromPublicKey(self: Module, publicKey: string): UserItem =
isBlocked = contactDetails.dto.isBlocked(),
isCurrentUser = contactDetails.isCurrentUser,
contactRequest = toContactStatus(contactDetails.dto.contactRequestState),
defaultDisplayName = contactDetails.defaultDisplayName,
optionalName = contactDetails.optionalName,
lastUpdated = contactDetails.dto.lastUpdated,
lastUpdatedLocally = contactDetails.dto.lastUpdatedLocally,
bio = contactDetails.dto.bio,
@ -96,7 +94,6 @@ proc createItemFromPublicKey(self: Module, publicKey: string): UserItem =
largeImage = contactDetails.dto.image.large,
isContactRequestReceived = contactDetails.dto.isContactRequestReceived,
isContactRequestSent = contactDetails.dto.isContactRequestSent,
isSyncing = contactDetails.dto.isSyncing,
isRemoved = contactDetails.dto.removed,
trustStatus = contactDetails.dto.trustStatus,
)

View File

@ -37,8 +37,6 @@ type
contactRequest: ContactRequest
#Contact extra details
isCurrentUser: bool
defaultDisplayName: string
optionalName: string
lastUpdated: int64
lastUpdatedLocally: int64
bio: string
@ -46,7 +44,6 @@ type
largeImage: string
isContactRequestReceived: bool
isContactRequestSent: bool
isSyncing: bool
isRemoved: bool
trustStatus: TrustStatus
@ -66,8 +63,6 @@ proc setup*(self: UserItem,
contactRequest: ContactRequest,
#TODO: #14964 - remove defaults
isCurrentUser: bool = false,
defaultDisplayName: string = "",
optionalName: string = "",
lastUpdated: int64 = 0,
lastUpdatedLocally: int64 = 0,
bio: string = "",
@ -75,7 +70,6 @@ proc setup*(self: UserItem,
largeImage: string = "",
isContactRequestReceived: bool = false,
isContactRequestSent: bool = false,
isSyncing: bool = false,
isRemoved: bool = false,
trustStatus: TrustStatus = TrustStatus.Unknown,
) =
@ -93,8 +87,6 @@ proc setup*(self: UserItem,
self.isBlocked = isBlocked
self.contactRequest = contactRequest
self.isCurrentUser = isCurrentUser
self.defaultDisplayName = defaultDisplayName
self.optionalName = optionalName
self.lastUpdated = lastUpdated
self.lastUpdatedLocally = lastUpdatedLocally
self.bio = bio
@ -102,7 +94,6 @@ proc setup*(self: UserItem,
self.largeImage = largeImage
self.isContactRequestReceived = isContactRequestReceived
self.isContactRequestSent = isContactRequestSent
self.isSyncing = isSyncing
self.isRemoved = isRemoved
self.trustStatus = trustStatus
@ -123,8 +114,6 @@ proc initUserItem*(
isBlocked: bool,
contactRequest: ContactRequest = ContactRequest.None,
isCurrentUser: bool = false,
defaultDisplayName: string = "",
optionalName: string = "",
lastUpdated: int64 = 0,
lastUpdatedLocally: int64 = 0,
bio: string = "",
@ -132,7 +121,6 @@ proc initUserItem*(
largeImage: string = "",
isContactRequestReceived: bool = false,
isContactRequestSent: bool = false,
isSyncing: bool = false,
isRemoved: bool = false,
trustStatus: TrustStatus = TrustStatus.Unknown,
): UserItem =
@ -152,8 +140,6 @@ proc initUserItem*(
isBlocked = isBlocked,
contactRequest = contactRequest,
isCurrentUser = isCurrentUser,
defaultDisplayName = defaultDisplayName,
optionalName = optionalName,
lastUpdated = lastUpdated,
lastUpdatedLocally = lastUpdatedLocally,
bio = bio,
@ -161,7 +147,6 @@ proc initUserItem*(
largeImage = largeImage,
isContactRequestReceived = isContactRequestReceived,
isContactRequestSent = isContactRequestSent,
isSyncing = isSyncing,
isRemoved = isRemoved,
trustStatus = trustStatus,
)
@ -182,8 +167,6 @@ proc `$`*(self: UserItem): string =
isBlocked: {self.isBlocked},
contactRequest: {$self.contactRequest.int},
isCurrentUser: {self.isCurrentUser},
defaultDisplayName: {self.defaultDisplayName},
optionalName: {self.optionalName},
lastUpdated: {self.lastUpdated},
lastUpdatedLocally: {self.lastUpdatedLocally},
bio: {self.bio},
@ -191,7 +174,6 @@ proc `$`*(self: UserItem): string =
largeImage: {self.largeImage},
isContactRequestReceived: {self.isContactRequestReceived},
isContactRequestSent: {self.isContactRequestSent},
isSyncing: {self.isSyncing},
isRemoved: {self.isRemoved},
trustStatus: {$self.trustStatus.int},
]"""
@ -277,18 +259,6 @@ proc isCurrentUser*(self: UserItem): bool {.inline.} =
proc `isCurrentUser=`*(self: UserItem, value: bool) {.inline.} =
self.isCurrentUser = value
proc defaultDisplayName*(self: UserItem): string {.inline.} =
self.defaultDisplayName
proc `defaultDisplayName=`*(self: UserItem, value: string) {.inline.} =
self.defaultDisplayName = value
proc optionalName*(self: UserItem): string {.inline.} =
self.optionalName
proc `optionalName=`*(self: UserItem, value: string) {.inline.} =
self.optionalName = value
proc lastUpdated*(self: UserItem): int64 {.inline.} =
self.lastUpdated
@ -331,12 +301,6 @@ proc isContactRequestSent*(self: UserItem): bool {.inline.} =
proc `isContactRequestSent=`*(self: UserItem, value: bool) {.inline.} =
self.isContactRequestSent = value
proc isSyncing*(self: UserItem): bool {.inline.} =
self.isSyncing
proc `isSyncing=`*(self: UserItem, value: bool) {.inline.} =
self.isSyncing = value
proc isRemoved*(self: UserItem): bool {.inline.} =
self.isRemoved

View File

@ -26,8 +26,6 @@ type
IsBlocked
ContactRequest
IsCurrentUser
DefaultDisplayName
OptionalName
LastUpdated
LastUpdatedLocally
Bio
@ -35,7 +33,6 @@ type
LargeImage
IsContactRequestReceived
IsContactRequestSent
IsSyncing
IsRemoved
TrustStatus
@ -102,8 +99,6 @@ QtObject:
ModelRole.IsBlocked.int: "isBlocked",
ModelRole.ContactRequest.int: "contactRequest",
ModelRole.IsCurrentUser.int: "isCurrentUser",
ModelRole.DefaultDisplayName.int: "defaultDisplayName",
ModelRole.OptionalName.int: "optionalName",
ModelRole.LastUpdated.int: "lastUpdated",
ModelRole.LastUpdatedLocally.int: "lastUpdatedLocally",
ModelRole.Bio.int: "bio",
@ -111,7 +106,6 @@ QtObject:
ModelRole.LargeImage.int: "largeImage",
ModelRole.IsContactRequestReceived.int: "isContactRequestReceived",
ModelRole.IsContactRequestSent.int: "isContactRequestSent",
ModelRole.IsSyncing.int: "isSyncing",
ModelRole.IsRemoved.int: "isRemoved",
ModelRole.TrustStatus.int: "trustStatus",
}.toTable
@ -164,12 +158,6 @@ QtObject:
result = newQVariant(item.contactRequest.int)
of ModelRole.IsCurrentUser:
result = newQVariant(item.isCurrentUser)
of ModelRole.DefaultDisplayName:
# TODO this is the same as preferred name
result = newQVariant(item.defaultDisplayName)
of ModelRole.OptionalName:
# This seems useless
result = newQVariant(item.optionalName)
of ModelRole.LastUpdated:
result = newQVariant(item.lastUpdated)
of ModelRole.LastUpdatedLocally:
@ -184,9 +172,6 @@ QtObject:
result = newQVariant(item.isContactRequestReceived)
of ModelRole.IsContactRequestSent:
result = newQVariant(item.isContactRequestSent)
of ModelRole.IsSyncing:
# TODO not sure what that is and it's never used
result = newQVariant(item.isSyncing)
of ModelRole.IsRemoved:
result = newQVariant(item.isRemoved)
of ModelRole.TrustStatus:

View File

@ -31,7 +31,6 @@ type ContactsDto* = object
added*: bool
blocked*: bool
hasAddedUs*: bool
isSyncing*: bool
removed*: bool
trustStatus*: TrustStatus
contactRequestState*: ContactRequestState
@ -58,7 +57,6 @@ proc `$`*(self: ContactsDto): string =
added:{self.added},
blocked:{self.blocked},
hasAddedUs:{self.hasAddedUs},
isSyncing:{self.isSyncing},
removed:{self.removed},
trustStatus:{self.trustStatus},
contactRequestState:{self.contactRequestState},
@ -116,7 +114,6 @@ proc toContactsDto*(jsonObj: JsonNode): ContactsDto =
discard jsonObj.getProp("added", result.added)
discard jsonObj.getProp("blocked", result.blocked)
discard jsonObj.getProp("hasAddedUs", result.hasAddedUs)
discard jsonObj.getProp("IsSyncing", result.isSyncing)
discard jsonObj.getProp("Removed", result.removed)
proc userExtractedName(contact: ContactsDto): string =

View File

@ -1,22 +1,14 @@
import QtQml 2.15
import QtTest 1.15
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import SortFilterProxyModel 0.2
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1
import Storybook 1.0
import utils 1.0
import Models 1.0
import AppLayouts.Profile.helpers 1.0
import AppLayouts.Profile.stores 1.0
import QtTest 1.15
SplitView {
id: root
@ -160,15 +152,13 @@ SplitView {
isUntrustworthy: false,
isBlocked: false,
contactRequestState: 3,
defaaaultDisplayName: "defaultDisplayName",
optionalName: "optionalName",
preferredDisplayName: "preferredDisplayName",
lastUpdated: 1234567890,
lastUpdatedLocally: 1234567890,
thumbnailImage: "thumbnailImage",
largeImage: "largeImage",
isContactRequestReceived: false,
isContactRequestSent: false,
isSyncing: false,
removed: false,
trustStatus: 1,
bio: "bio"
@ -185,7 +175,7 @@ SplitView {
readonly property int colorId: 1
readonly property var colorHash: {}
readonly property int currentUserStatus: 1
readonly property string defaultDisplayName: "myDefaultDisplayName"
readonly property string preferredDisplayName: "myPreferredDisplayName"
readonly property string thumbnailImage: "myThumbnailImage"
readonly property string largeImage: "myLargeImage"
readonly property string bio: "myBio"
@ -199,3 +189,6 @@ SplitView {
}
}
// category: Contacts
// Page is working in general but throwing multiple "Cannot read property" when changing id via combo box
// status: decent

View File

@ -46,15 +46,13 @@ Item {
isUntrustworthy: false,
isBlocked: false,
contactRequest: 3,
defaultDisplayName: "defaultDisplayName",
optionalName: "optionalName",
preferredDisplayName: "preferredDisplayName",
lastUpdated: 1234567890,
lastUpdatedLocally: 1234567890,
thumbnailImage: "thumbnailImage",
largeImage: "largeImage",
isContactRequestReceived: false,
isContactRequestSent: false,
isSyncing: false,
isRemoved: false,
trustStatus: 1,
bio: "bio"
@ -74,7 +72,7 @@ Item {
readonly property int colorId: 1
readonly property var colorHash: {1}
readonly property int currentUserStatus: 1
readonly property string defaultDisplayName: "myDefaultDisplayName"
readonly property string preferredDisplayName: "myPreferredDisplayName"
readonly property string thumbnailImage: "myThumbnailImage"
readonly property string largeImage: "myLargeImage"
readonly property string bio: "myBio"
@ -149,13 +147,11 @@ Item {
compare(contactDetails.isUntrustworthy, false, "Expected the isUntrustworthy flag to be set")
compare(contactDetails.isBlocked, false, "Expected the isBlocked flag to be set")
compare(contactDetails.contactRequestState, 3, "Expected the contactRequestState flag to be set")
compare(contactDetails.defaultDisplayName, "defaultDisplayName", "Expected the defaultDisplayName to be set")
compare(contactDetails.optionalName, "optionalName", "Expected the optionalName to be set")
compare(contactDetails.preferredDisplayName, "preferredDisplayName", "Expected the preferredDisplayName to be set")
compare(contactDetails.lastUpdated, 1234567890, "Expected the lastUpdated to be set")
compare(contactDetails.lastUpdatedLocally, 1234567890, "Expected the lastUpdatedLocally to be set")
compare(contactDetails.isContactRequestReceived, false, "Expected the isContactRequestReceived flag to be set")
compare(contactDetails.isContactRequestSent, false, "Expected the isContactRequestSent flag to be set")
compare(contactDetails.isSyncing, false, "Expected the isSyncing to be set")
compare(contactDetails.removed, false, "Expected the removed flag to be set")
compare(contactDetails.trustStatus, 1, "Expected the trustStatus flag to be set")
}
@ -256,15 +252,13 @@ Item {
isUntrustworthy: true,
isBlocked: true,
contactRequest: 2,
defaultDisplayName: "newDefaultDisplayName",
optionalName: "newOptionalName",
preferredDisplayName: "newPreferredDisplayName",
lastUpdated: 1234567891,
lastUpdatedLocally: 1234567891,
thumbnailImage: "newThumbnailImage",
largeImage: "newLargeImage",
isContactRequestReceived: true,
isContactRequestSent: true,
isSyncing: true,
isRemoved: true,
trustStatus: 2,
bio: "newBio"
@ -289,13 +283,11 @@ Item {
compare(contactDetails.isUntrustworthy, true, "Expected the isUntrustworthy flag to be set")
compare(contactDetails.isBlocked, true, "Expected the isBlocked flag to be set")
compare(contactDetails.contactRequestState, 2, "Expected the contactRequestState flag to be set")
compare(contactDetails.defaultDisplayName, "newDefaultDisplayName", "Expected the defaultDisplayName to be set")
compare(contactDetails.optionalName, "newOptionalName", "Expected the optionalName to be set")
compare(contactDetails.preferredDisplayName, "newPreferredDisplayName", "Expected the preferredDisplayName to be set")
compare(contactDetails.lastUpdated, 1234567891, "Expected the lastUpdated to be set")
compare(contactDetails.lastUpdatedLocally, 1234567891, "Expected the lastUpdatedLocally to be set")
compare(contactDetails.isContactRequestReceived, true, "Expected the isContactRequestReceived flag to be set")
compare(contactDetails.isContactRequestSent, true, "Expected the isContactRequestSent flag to be set")
compare(contactDetails.isSyncing, true, "Expected the isSyncing to be set")
compare(contactDetails.removed, true, "Expected the removed flag to be set")
compare(contactDetails.trustStatus, 2, "Expected the trustStatus flag to be set")
}
@ -325,4 +317,4 @@ Item {
compare(contactDetails.localNickname, "localNickname", "Expected the local nickname to be set")
}
}
}
}

View File

@ -32,15 +32,13 @@ QObject {
readonly property bool isUntrustworthy: d.contactDetails.isUntrustworthy ?? false
readonly property bool isBlocked: d.contactDetails.isBlocked ?? false
readonly property int contactRequestState: d.contactDetails.contactRequest ?? Constants.ContactRequestState.None
readonly property string defaultDisplayName: d.contactDetails.defaultDisplayName ?? ""
readonly property string optionalName: d.contactDetails.optionalName ?? ""
readonly property string preferredDisplayName: d.contactDetails.preferredDisplayName ?? ""
readonly property int lastUpdated: d.contactDetails.lastUpdated ?? 0
readonly property int lastUpdatedLocally: d.contactDetails.lastUpdatedLocally ?? 0
readonly property string thumbnailImage: d.contactDetails.thumbnailImage ?? ""
readonly property string largeImage: d.contactDetails.largeImage ?? ""
readonly property bool isContactRequestReceived: d.contactDetails.isContactRequestReceived ?? false
readonly property bool isContactRequestSent: d.contactDetails.isContactRequestSent ?? false
readonly property bool isSyncing: d.contactDetails.isSyncing ?? false
readonly property bool removed: d.contactDetails.isRemoved ?? false
readonly property int trustStatus: d.contactDetails.trustStatus ?? Constants.trustStatus.unknown
readonly property string bio: d.contactDetails.bio ?? ""
@ -76,6 +74,8 @@ QObject {
readonly property string ensName: root.profileStore.name
readonly property bool isEnsVerified: root.profileStore.name !== "" && Utils.isValidEns(root.profileStore.name)
readonly property string localNickname: ""
readonly property string preferredDisplayName: root.profileStore.preferredDisplayName
readonly property string name: preferredDisplayName
readonly property string alias: root.profileStore.username
readonly property string icon: root.profileStore.icon
readonly property int colorId: root.profileStore.colorId
@ -87,16 +87,12 @@ QObject {
readonly property bool isUntrustworthy: false
readonly property bool isBlocked: false
readonly property int contactRequestState: Constants.ContactRequestState.None
readonly property string defaultDisplayName: root.profileStore.defaultDisplayName
readonly property string optionalName: defaultDisplayName
readonly property string name: defaultDisplayName
readonly property int lastUpdated: 0
readonly property int lastUpdatedLocally: 0
readonly property string thumbnailImage: root.profileStore.thumbnailImage
readonly property string largeImage: root.profileStore.largeImage
readonly property bool isContactRequestReceived: Constants.ContactRequestState.None
readonly property bool isContactRequestSent: Constants.ContactRequestState.None
readonly property bool isSyncing: false
readonly property bool removed: false
readonly property int trustStatus: Constants.trustStatus.unknown
readonly property string bio: root.profileStore.bio

View File

@ -24,9 +24,7 @@ QtObject {
readonly property var thumbnailImage: userProfile.thumbnailImage
readonly property var largeImage: userProfile.largeImage
readonly property int colorId: Utils.colorIdForPubkey(root.pubkey)
readonly property var colorHash: Utils.getColorHashAsJson(root.pubkey)
readonly property string defaultDisplayName: ProfileUtils.displayName("", name, displayName, username)
readonly property string bio: profileModule.bio
readonly property string socialLinksJson: profileModule.socialLinksJson

View File

@ -738,8 +738,6 @@ QtObject {
function getContactDetailsAsJson(publicKey, getVerificationRequest=true, getOnlineStatus=false, includeDetails=false) {
const defaultValue = {
defaultDisplayName: "",
optionalName: "",
icon: "",
isCurrentUser: "",
colorId: "",
@ -759,7 +757,6 @@ QtObject {
isBlocked: false,
isContactRequestReceived: false,
isContactRequestSent: false,
isSyncing: false,
removed: false,
trustStatus: Constants.trustStatus.unknown,
contactRequestState: Constants.ContactRequestState.None,