Trending posts
This commit is contained in:
parent
79bf9a0486
commit
afc2069c2c
|
@ -539,6 +539,12 @@
|
|||
"state" : "translated",
|
||||
"value" : "Found posts"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Publications trouvées"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -549,6 +555,12 @@
|
|||
"state" : "translated",
|
||||
"value" : "Found tags"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Tags trouvés"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -559,6 +571,12 @@
|
|||
"state" : "translated",
|
||||
"value" : "Found users"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Utilisateurs trouvés"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -601,6 +619,12 @@
|
|||
"state" : "translated",
|
||||
"value" : "Tags"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Tags"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -636,6 +660,22 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"discovery.trending.posts" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Trending Posts"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Publications en vedette"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"discovery.trending.tags" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
|
|
|
@ -51,6 +51,13 @@ struct DiscoveryView: View {
|
|||
.padding(.horizontal)
|
||||
|
||||
tagsView
|
||||
|
||||
Text("discovery.trending.posts")
|
||||
.multilineTextAlignment(.leading)
|
||||
.font(.title.bold())
|
||||
.padding(.horizontal)
|
||||
|
||||
statusView
|
||||
}
|
||||
}
|
||||
.submitLabel(.search)
|
||||
|
@ -129,7 +136,6 @@ struct DiscoveryView: View {
|
|||
}
|
||||
|
||||
var tagsView: some View {
|
||||
ScrollView {
|
||||
VStack(spacing: 7.5) {
|
||||
ForEach(trendingTags) { tag in
|
||||
HStack {
|
||||
|
@ -147,23 +153,33 @@ struct DiscoveryView: View {
|
|||
Spacer()
|
||||
|
||||
Button {
|
||||
// do stuff
|
||||
navigator.navigate(to: .timeline(timeline: .hashtag(tag: tag.name, accountId: nil)))
|
||||
} label: {
|
||||
Text("tag.read")
|
||||
}
|
||||
.buttonStyle(LargeButton(filled: true, height: 7.5))
|
||||
.buttonStyle(LargeButton(filled: true, height: 7.5, disabled: true))
|
||||
.disabled(true)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var statusView: some View {
|
||||
VStack(spacing: 7.5) {
|
||||
ForEach(trendingStatuses) { status in
|
||||
CompactPostView(status: status)
|
||||
.padding(.vertical)
|
||||
.environmentObject(navigator)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func search() async {
|
||||
guard let client = accountManager.getClient(), !searchQuery.isEmpty else { return }
|
||||
do {
|
||||
try await Task.sleep(for: .milliseconds(250))
|
||||
var results: SearchResults = try await client.get(endpoint: Search.search(query: searchQuery, type: currentTokens.first?.id, offset: nil, following: nil), forceVersion: .v2)
|
||||
let results: SearchResults = try await client.get(endpoint: Search.search(query: searchQuery, type: currentTokens.first?.id, offset: nil, following: nil), forceVersion: .v2)
|
||||
// let relationships: [Relationship] = try await client.get(endpoint: Accounts.relationships(ids: results.accounts.map(\.id)))
|
||||
// results.relationships = relationships
|
||||
withAnimation {
|
||||
|
@ -183,6 +199,8 @@ struct DiscoveryView: View {
|
|||
trendingStatuses = data.trendingStatuses
|
||||
trendingLinks = data.trendingLinks
|
||||
|
||||
trendingTags = trendingTags.sorted(by: { $0.totalUses > $1.totalUses })
|
||||
|
||||
suggestedAccountsRelationShips = try await client.get(endpoint: Accounts.relationships(ids: suggestedAccounts.map(\.id)))
|
||||
} catch {
|
||||
print(error)
|
||||
|
|
Loading…
Reference in New Issue