fix: Hide members count from community cards when the community is encrypted and the community info is not available
This commit is contained in:
parent
18adfbe6fa
commit
85066fccc8
|
@ -16,6 +16,8 @@ type
|
||||||
featured: bool
|
featured: bool
|
||||||
permissionModel: TokenPermissionsModel
|
permissionModel: TokenPermissionsModel
|
||||||
amIBanned: bool
|
amIBanned: bool
|
||||||
|
joined: bool
|
||||||
|
encrypted: bool
|
||||||
|
|
||||||
proc initCuratedCommunityItem*(
|
proc initCuratedCommunityItem*(
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -30,7 +32,9 @@ proc initCuratedCommunityItem*(
|
||||||
activeMembers: int,
|
activeMembers: int,
|
||||||
featured: bool,
|
featured: bool,
|
||||||
tokenPermissionsItems: seq[TokenPermissionItem],
|
tokenPermissionsItems: seq[TokenPermissionItem],
|
||||||
amIBanned: bool
|
amIBanned: bool,
|
||||||
|
joined: bool,
|
||||||
|
encrypted: bool
|
||||||
): CuratedCommunityItem =
|
): CuratedCommunityItem =
|
||||||
result.id = id
|
result.id = id
|
||||||
result.name = name
|
result.name = name
|
||||||
|
@ -47,6 +51,8 @@ proc initCuratedCommunityItem*(
|
||||||
if tokenPermissionsItems.len > 0:
|
if tokenPermissionsItems.len > 0:
|
||||||
result.permissionModel.setItems(tokenPermissionsItems)
|
result.permissionModel.setItems(tokenPermissionsItems)
|
||||||
result.amIBanned = amIBanned
|
result.amIBanned = amIBanned
|
||||||
|
result.joined = joined
|
||||||
|
result.encrypted = encrypted
|
||||||
|
|
||||||
proc `$`*(self: CuratedCommunityItem): string =
|
proc `$`*(self: CuratedCommunityItem): string =
|
||||||
result = fmt"""CuratedCommunityItem(
|
result = fmt"""CuratedCommunityItem(
|
||||||
|
@ -60,6 +66,8 @@ proc `$`*(self: CuratedCommunityItem): string =
|
||||||
activeMembers: {self.activeMembers}
|
activeMembers: {self.activeMembers}
|
||||||
featured: {self.featured}
|
featured: {self.featured}
|
||||||
amIBanned: {self.amIBanned}
|
amIBanned: {self.amIBanned}
|
||||||
|
joined: {self.joined}
|
||||||
|
encrypted: {self.encrypted}
|
||||||
]"""
|
]"""
|
||||||
|
|
||||||
proc getId*(self: CuratedCommunityItem): string =
|
proc getId*(self: CuratedCommunityItem): string =
|
||||||
|
@ -102,4 +110,10 @@ proc setPermissionModelItems*(self: CuratedCommunityItem, items: seq[TokenPermis
|
||||||
self.permissionModel.setItems(items)
|
self.permissionModel.setItems(items)
|
||||||
|
|
||||||
proc getAmIBanned*(self: CuratedCommunityItem): bool =
|
proc getAmIBanned*(self: CuratedCommunityItem): bool =
|
||||||
return self.amIBanned
|
return self.amIBanned
|
||||||
|
|
||||||
|
proc getJoined*(self: CuratedCommunityItem): bool =
|
||||||
|
return self.joined
|
||||||
|
|
||||||
|
proc getEncrypted*(self: CuratedCommunityItem): bool =
|
||||||
|
return self.encrypted
|
||||||
|
|
|
@ -18,6 +18,8 @@ type
|
||||||
Tags
|
Tags
|
||||||
Permissions
|
Permissions
|
||||||
AmIBanned
|
AmIBanned
|
||||||
|
Joined
|
||||||
|
Encrypted
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type CuratedCommunityModel* = ref object of QAbstractListModel
|
type CuratedCommunityModel* = ref object of QAbstractListModel
|
||||||
|
@ -67,6 +69,8 @@ QtObject:
|
||||||
ModelRole.Tags.int:"tags",
|
ModelRole.Tags.int:"tags",
|
||||||
ModelRole.Permissions.int:"permissionsModel",
|
ModelRole.Permissions.int:"permissionsModel",
|
||||||
ModelRole.AmIBanned.int:"amIBanned",
|
ModelRole.AmIBanned.int:"amIBanned",
|
||||||
|
ModelRole.Joined.int:"joined",
|
||||||
|
ModelRole.Encrypted.int:"encrypted"
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
method data(self: CuratedCommunityModel, index: QModelIndex, role: int): QVariant =
|
method data(self: CuratedCommunityModel, index: QModelIndex, role: int): QVariant =
|
||||||
|
@ -106,6 +110,10 @@ QtObject:
|
||||||
result = newQVariant(item.getFeatured())
|
result = newQVariant(item.getFeatured())
|
||||||
of ModelRole.AmIBanned:
|
of ModelRole.AmIBanned:
|
||||||
result = newQVariant(item.getAmIBanned())
|
result = newQVariant(item.getAmIBanned())
|
||||||
|
of ModelRole.Joined:
|
||||||
|
result = newQVariant(item.getJoined())
|
||||||
|
of ModelRole.Encrypted:
|
||||||
|
result = newQVariant(item.getEncrypted())
|
||||||
|
|
||||||
proc findIndexById(self: CuratedCommunityModel, id: string): int =
|
proc findIndexById(self: CuratedCommunityModel, id: string): int =
|
||||||
for i in 0 ..< self.items.len:
|
for i in 0 ..< self.items.len:
|
||||||
|
|
|
@ -274,7 +274,9 @@ proc getCuratedCommunityItem(self: Module, community: CommunityDto): CuratedComm
|
||||||
int(community.activeMembersCount),
|
int(community.activeMembersCount),
|
||||||
community.featuredInDirectory,
|
community.featuredInDirectory,
|
||||||
tokenPermissionsItems,
|
tokenPermissionsItems,
|
||||||
amIbanned
|
amIbanned,
|
||||||
|
community.joined,
|
||||||
|
community.encrypted,
|
||||||
)
|
)
|
||||||
|
|
||||||
proc getDiscordCategoryItem(self: Module, c: DiscordCategoryDto): DiscordCategoryItem =
|
proc getDiscordCategoryItem(self: Module, c: DiscordCategoryDto): DiscordCategoryItem =
|
||||||
|
|
|
@ -14,6 +14,8 @@ QtObject:
|
||||||
color: string
|
color: string
|
||||||
icon: LinkPreviewThumbnail
|
icon: LinkPreviewThumbnail
|
||||||
banner: LinkPreviewThumbnail
|
banner: LinkPreviewThumbnail
|
||||||
|
encrypted: bool
|
||||||
|
joined: bool
|
||||||
|
|
||||||
proc setup*(self: StatusCommunityLinkPreview) =
|
proc setup*(self: StatusCommunityLinkPreview) =
|
||||||
self.QObject.setup()
|
self.QObject.setup()
|
||||||
|
@ -74,6 +76,22 @@ QtObject:
|
||||||
proc getBanner*(self: StatusCommunityLinkPreview): LinkPreviewThumbnail =
|
proc getBanner*(self: StatusCommunityLinkPreview): LinkPreviewThumbnail =
|
||||||
result = self.banner
|
result = self.banner
|
||||||
|
|
||||||
|
proc getEncrypted*(self: StatusCommunityLinkPreview): bool {.slot.} =
|
||||||
|
result = self.encrypted
|
||||||
|
proc encryptedChanged*(self: StatusCommunityLinkPreview) {.signal.}
|
||||||
|
|
||||||
|
QtProperty[bool] encrypted:
|
||||||
|
read = getEncrypted
|
||||||
|
notify = encryptedChanged
|
||||||
|
|
||||||
|
proc getJoined*(self: StatusCommunityLinkPreview): bool {.slot.} =
|
||||||
|
result = self.joined
|
||||||
|
proc joinedChanged*(self: StatusCommunityLinkPreview) {.signal.}
|
||||||
|
|
||||||
|
QtProperty[bool] joined:
|
||||||
|
read = getJoined
|
||||||
|
notify = joinedChanged
|
||||||
|
|
||||||
proc toStatusCommunityLinkPreview*(jsonObj: JsonNode): StatusCommunityLinkPreview =
|
proc toStatusCommunityLinkPreview*(jsonObj: JsonNode): StatusCommunityLinkPreview =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.setup()
|
result.setup()
|
||||||
|
@ -108,7 +126,9 @@ QtObject:
|
||||||
activeMembersCount: {self.activeMembersCount},
|
activeMembersCount: {self.activeMembersCount},
|
||||||
color: {self.color},
|
color: {self.color},
|
||||||
icon: {self.icon},
|
icon: {self.icon},
|
||||||
banner: {self.banner}
|
banner: {self.banner},
|
||||||
|
encrypted: {self.encrypted},
|
||||||
|
joined: {self.joined}
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
proc `%`*(self: StatusCommunityLinkPreview): JsonNode =
|
proc `%`*(self: StatusCommunityLinkPreview): JsonNode =
|
||||||
|
@ -120,7 +140,9 @@ QtObject:
|
||||||
"activeMembersCount": self.activeMembersCount,
|
"activeMembersCount": self.activeMembersCount,
|
||||||
"color": self.color,
|
"color": self.color,
|
||||||
"icon": self.icon,
|
"icon": self.icon,
|
||||||
"banner": self.banner
|
"banner": self.banner,
|
||||||
|
"encrypted": self.encrypted,
|
||||||
|
"joined": self.joined
|
||||||
}
|
}
|
||||||
|
|
||||||
proc empty*(self: StatusCommunityLinkPreview): bool =
|
proc empty*(self: StatusCommunityLinkPreview): bool =
|
||||||
|
@ -155,4 +177,12 @@ QtObject:
|
||||||
self.icon.update(0, 0, "", community.images.thumbnail)
|
self.icon.update(0, 0, "", community.images.thumbnail)
|
||||||
self.banner.update(0, 0, "", community.images.banner)
|
self.banner.update(0, 0, "", community.images.banner)
|
||||||
|
|
||||||
|
if self.encrypted != community.encrypted:
|
||||||
|
self.encrypted = community.encrypted
|
||||||
|
self.encryptedChanged()
|
||||||
|
|
||||||
|
if self.joined != community.joined:
|
||||||
|
self.joined = community.joined
|
||||||
|
self.joinedChanged()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -391,7 +391,7 @@ Rectangle {
|
||||||
// Bottom Row extra info component
|
// Bottom Row extra info component
|
||||||
Loader {
|
Loader {
|
||||||
id: bottomRowLoader
|
id: bottomRowLoader
|
||||||
Layout.fillWidth: (!!item && item.width===0)
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 24
|
Layout.preferredHeight: 24
|
||||||
active: ((root.categories.count > 0) || !!root.bottomRowComponent)
|
active: ((root.categories.count > 0) || !!root.bottomRowComponent)
|
||||||
sourceComponent: tagsListComponent
|
sourceComponent: tagsListComponent
|
||||||
|
|
|
@ -83,6 +83,7 @@ StatusScrollView {
|
||||||
activeUsers: model.activeMembers
|
activeUsers: model.activeMembers
|
||||||
popularity: model.popularity
|
popularity: model.popularity
|
||||||
categories: tagsJson.model
|
categories: tagsJson.model
|
||||||
|
memberCountVisible: model.joined || !model.encrypted
|
||||||
|
|
||||||
|
|
||||||
// Community restrictions
|
// Community restrictions
|
||||||
|
|
|
@ -253,7 +253,7 @@ CalloutCard {
|
||||||
PropertyChanges { target: title; text: root.communityData.name }
|
PropertyChanges { target: title; text: root.communityData.name }
|
||||||
PropertyChanges { target: description; text: root.communityData.description }
|
PropertyChanges { target: description; text: root.communityData.description }
|
||||||
PropertyChanges { target: d; bannerImageSource: root.communityData.banner }
|
PropertyChanges { target: d; bannerImageSource: root.communityData.banner }
|
||||||
PropertyChanges { target: footerLoader; active: true; visible: true; sourceComponent: communityFooterComponent }
|
PropertyChanges { target: footerLoader; active: true; visible: !root.communityData.encrypted || root.communityData.joined; sourceComponent: communityFooterComponent }
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "channel"
|
name: "channel"
|
||||||
|
|
|
@ -8,5 +8,7 @@ QtObject {
|
||||||
property string color
|
property string color
|
||||||
property int membersCount
|
property int membersCount
|
||||||
property int activeMembersCount // -1 when not available. >= 0 otherwise.
|
property int activeMembersCount // -1 when not available. >= 0 otherwise.
|
||||||
|
property bool encrypted
|
||||||
|
property bool joined
|
||||||
readonly property bool activeMembersCountAvailable: activeMembersCount >= 0
|
readonly property bool activeMembersCountAvailable: activeMembersCount >= 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,8 @@ LinkPreviewCard {
|
||||||
membersCount: statusCommunityPreview ? statusCommunityPreview.membersCount : 0
|
membersCount: statusCommunityPreview ? statusCommunityPreview.membersCount : 0
|
||||||
activeMembersCount: statusCommunityPreview && isLocalData ? statusCommunityPreview.activeMembersCount : -1
|
activeMembersCount: statusCommunityPreview && isLocalData ? statusCommunityPreview.activeMembersCount : -1
|
||||||
color: statusCommunityPreview ? statusCommunityPreview.color : ""
|
color: statusCommunityPreview ? statusCommunityPreview.color : ""
|
||||||
|
encrypted: statusCommunityPreview ? statusCommunityPreview.encrypted : false
|
||||||
|
joined: statusCommunityPreview ? statusCommunityPreview.joined : false
|
||||||
}
|
}
|
||||||
channelData {
|
channelData {
|
||||||
name: statusCommunityChannelPreview ? statusCommunityChannelPreview.displayName : ""
|
name: statusCommunityChannelPreview ? statusCommunityChannelPreview.displayName : ""
|
||||||
|
|
Loading…
Reference in New Issue