Skip to content

Commit

Permalink
feat: author feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
vaultec81 committed Mar 28, 2023
1 parent 29977ab commit 22a5334
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 47 deletions.
86 changes: 41 additions & 45 deletions src/renderer/components/hooks/Feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,47 @@ import { gql, useQuery } from '@apollo/client'
import { useEffect, useMemo } from 'react'
import { IndexerClient } from '../../App'

const LATEST_BY_USERNAME = gql`
query Query($author: String) {
latestFeed(author: $author, limit: 15) {
const LATEST_FEED_AUTHOR = gql`
query AuthorFeed($id: String) {
feed: socialFeed(feedOptions: {
byCreator: {
_eq: $id
}
}) {
items {
... on CeramicPost {
stream_id
version_id
parent_id
title
body
json_metadata
app_metadata
}
body
created_at
parent_author
parent_permlink
permlink
title
updated_at
... on HivePost {
created_at
updated_at
parent_author
parent_permlink
author {
username
}
json_metadata {
raw
}
stats {
num_comments
num_votes
total_hive_reward
}
app_metadata
spkvideo
refs
post_type
permlink
author
title
body
lang
post_type
app
tags
json_metadata
app_metadata
community_ref
three_video
# children {
# parent_author
# parent_permlink
# permlink
# title
# body
# title
# lang
# post_type
# app
# json_metadata
# app_metadata
# community_ref
# }
updated_at
body
community
created_at
}
__typename
}
}
}
Expand Down Expand Up @@ -183,10 +176,10 @@ query TrendingFeed {
`

const LATEST_COMMUNITY_FEED = gql`
query LatestCommunityFeed($community: String) {
query LatestCommunityFeed($id: String) {
latestFeed(feedOptions: {
byCommunity: {
_id: $community
_id: $id
}
}) {
items {
Expand Down Expand Up @@ -229,10 +222,10 @@ const LATEST_COMMUNITY_FEED = gql`
`

const TRENDING_COMMUNITY_FEED = gql`
query LatestCommunityFeed($community: String) {
query LatestCommunityFeed($id: String) {
trendingFeed(feedOptions: {
byCommunity: {
_id: $community
_id: $id
}
}) {
items {
Expand Down Expand Up @@ -321,13 +314,16 @@ export function useGraphqlFeed(props: any) {
query = LATEST_COMMUNITY_FEED
} else if(props.type === "community-trends") {
query = TRENDING_COMMUNITY_FEED
} else if(props.type === "author-feed") {
query = LATEST_FEED_AUTHOR;
} else {
query = LATEST_FEED
}

const { data, loading, refetch } = useQuery(query, {
client: IndexerClient,
variables: {
community: props.community
id: props.id,
}
})

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/views/GridFeedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface GridFeedProps {
awaitingMoreData?: boolean
type: string
community?: string
username?: string
data?: any[]
titleText?: string
}
Expand All @@ -32,7 +33,7 @@ export function GridFeedView(props: GridFeedProps) {

const videos = useGraphqlFeed({
type: props.type,
community: props.community
id: props.community || props.username
})

const reflink = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/UserView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function UserView(props: any) {
<Switch>
<Route exact path={`/user/${reflink.toString()}`}>
<section className="content_home" style={{ height: 'auto !important' }}>
<GridFeedView type={'@' + username} awaitingMoreData={true} data={transformGraphqlToNormal(videos)}/>
<GridFeedView username={username} type={'author-feed'} awaitingMoreData={true}/>
</section>
</Route>
<Route path={`/user/${reflink.toString()}/earning`}>
Expand Down

0 comments on commit 22a5334

Please sign in to comment.