parent
935ab046e6
commit
cc191ae0e4
|
@ -12,6 +12,7 @@ type
|
|||
tags: string
|
||||
members: int
|
||||
activeMembers: int
|
||||
featured: bool
|
||||
|
||||
proc initCuratedCommunityItem*(
|
||||
id: string,
|
||||
|
@ -23,7 +24,8 @@ proc initCuratedCommunityItem*(
|
|||
color: string,
|
||||
tags: string,
|
||||
members: int,
|
||||
activeMembers: int
|
||||
activeMembers: int,
|
||||
featured: bool
|
||||
): CuratedCommunityItem =
|
||||
result.id = id
|
||||
result.name = name
|
||||
|
@ -35,6 +37,7 @@ proc initCuratedCommunityItem*(
|
|||
result.tags = tags
|
||||
result.members = members
|
||||
result.activeMembers = activeMembers
|
||||
result.featured = featured
|
||||
|
||||
proc `$`*(self: CuratedCommunityItem): string =
|
||||
result = fmt"""CuratedCommunityItem(
|
||||
|
@ -46,6 +49,7 @@ proc `$`*(self: CuratedCommunityItem): string =
|
|||
tags: {self.tags},
|
||||
members: {self.members}
|
||||
activeMembers: {self.activeMembers}
|
||||
featured: {self.featured}
|
||||
]"""
|
||||
|
||||
proc getId*(self: CuratedCommunityItem): string =
|
||||
|
@ -77,3 +81,6 @@ proc getColor*(self: CuratedCommunityItem): string =
|
|||
|
||||
proc getTags*(self: CuratedCommunityItem): string =
|
||||
return self.tags
|
||||
|
||||
proc getFeatured*(self: CuratedCommunityItem): bool =
|
||||
return self.featured
|
||||
|
|
|
@ -61,7 +61,7 @@ QtObject:
|
|||
ModelRole.ActiveMembers.int:"activeMembers",
|
||||
ModelRole.Color.int:"color",
|
||||
ModelRole.Popularity.int:"popularity",
|
||||
ModelRole.Tags.int:"tags"
|
||||
ModelRole.Tags.int:"tags",
|
||||
}.toTable
|
||||
|
||||
method data(self: CuratedCommunityModel, index: QModelIndex, role: int): QVariant =
|
||||
|
@ -96,11 +96,7 @@ QtObject:
|
|||
of ModelRole.Tags:
|
||||
result = newQVariant(item.getTags())
|
||||
of ModelRole.Featured:
|
||||
# TODO: replace this with a real value
|
||||
var featured = false
|
||||
if index.row < 3:
|
||||
featured = true
|
||||
result = newQVariant(featured)
|
||||
result = newQVariant(item.getFeatured())
|
||||
|
||||
proc findIndexById(self: CuratedCommunityModel, id: string): int =
|
||||
for i in 0 ..< self.items.len:
|
||||
|
|
|
@ -194,7 +194,8 @@ proc getCuratedCommunityItem(self: Module, c: CommunityDto): CuratedCommunityIte
|
|||
c.color,
|
||||
c.tags,
|
||||
len(c.members),
|
||||
int(c.activeMembersCount))
|
||||
int(c.activeMembersCount),
|
||||
c.featuredInDirectory)
|
||||
|
||||
proc getDiscordCategoryItem(self: Module, c: DiscordCategoryDto): DiscordCategoryItem =
|
||||
return initDiscordCategoryItem(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{.used.}
|
||||
|
||||
import std/jsonutils
|
||||
import json, sequtils, sugar, tables, strutils, json_serialization
|
||||
|
||||
import ../../../../backend/communities
|
||||
|
@ -91,6 +92,7 @@ type CommunityDto* = object
|
|||
isMember*: bool
|
||||
muted*: bool
|
||||
listedInDirectory*: bool
|
||||
featuredInDirectory*: bool
|
||||
pendingRequestsToJoin*: seq[CommunityMembershipRequestDto]
|
||||
settings*: CommunitySettingsDto
|
||||
adminSettings*: CommunityAdminSettingsDto
|
||||
|
@ -355,6 +357,11 @@ proc parseCuratedCommunities*(response: JsonNode): seq[CommunityDto] =
|
|||
result = parseKnownCuratedCommunities(response["communities"])
|
||||
if (response["unknownCommunities"].kind == JArray):
|
||||
result = concat(result, parseUnknownCuratedCommunities(response["unknownCommunities"]))
|
||||
if (response["contractFeaturedCommunities"].kind == JArray):
|
||||
let featuredCommunityIDs = response["contractFeaturedCommunities"].to(seq[string])
|
||||
for i in 0..<result.len:
|
||||
let communityID = result[i].id
|
||||
result[i].featuredInDirectory = any(featuredCommunityIDs, id => id == communityID)
|
||||
|
||||
proc contains(arrayToSearch: seq[int], searched: int): bool =
|
||||
for element in arrayToSearch:
|
||||
|
|
Loading…
Reference in New Issue