From 3116af0ec984d057cc682288824de4b6b75779c2 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Fri, 9 Sep 2022 17:08:17 +0300 Subject: [PATCH] home-topics-one --- src/components/Views/Feed.tsx | 4 +++- src/pages/feed/index.astro | 4 ++-- src/pages/index.astro | 2 +- src/utils/apiClient.ts | 26 ++++++++++---------------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/components/Views/Feed.tsx b/src/components/Views/Feed.tsx index 2bea15a3..0eef0472 100644 --- a/src/components/Views/Feed.tsx +++ b/src/components/Views/Feed.tsx @@ -56,7 +56,9 @@ export const FeedPage = (props: FeedProps) => { // TODO: list of articles where you are co-author // TODO: preload proposals // TODO: (maybe?) and changes history - console.debug(reactions().filter((r) => r.kind in AUTHORSHIP_REACTIONS)) // 2 community self-regulating mechanics + console.debug(reactions().filter((r) => r.kind in AUTHORSHIP_REACTIONS)) + + // 2 community self-regulating mechanics // TODO: query all new posts to be rated for publishing // TODO: query all reactions where user is in authors list return [] diff --git a/src/pages/feed/index.astro b/src/pages/feed/index.astro index c96115ca..63fa14a4 100644 --- a/src/pages/feed/index.astro +++ b/src/pages/feed/index.astro @@ -3,11 +3,11 @@ import { FeedPage } from '../../components/Views/Feed' import Zine from '../../layouts/zine.astro' import { apiClient } from '../../utils/apiClient' -const recentArticles = await apiClient.getRecentArticles({ page: 1 }) +const recentArticles = await apiClient.getRecentAllArticles({}) const shoutSlugs = recentArticles.map((s) => s.slug) const reactions = await apiClient.getReactionsForShouts({ shoutSlugs }) --- - + diff --git a/src/pages/index.astro b/src/pages/index.astro index 26beed88..c35448b7 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -4,7 +4,7 @@ import Zine from '../layouts/zine.astro' import { apiClient } from '../utils/apiClient' const randomTopics = await apiClient.getRandomTopics() -const recentPublished = await apiClient.getRecentPublishedArticles() +const recentPublished = await apiClient.getRecentPublishedArticles({}) const topMonth = await apiClient.getTopMonthArticles() const topOverall = await apiClient.getTopArticles() diff --git a/src/utils/apiClient.ts b/src/utils/apiClient.ts index ecfe0e60..0a78df1e 100644 --- a/src/utils/apiClient.ts +++ b/src/utils/apiClient.ts @@ -99,7 +99,7 @@ export const apiClient = { }) .toPromise() - return response.data.recentAll + return response.data.recentPublished }, getArticlesForTopics: async ({ topicSlugs, @@ -153,15 +153,15 @@ export const apiClient = { // auth - signIn: async({ email, password }) => { + signIn: async ({ email, password }) => { const response = await publicGraphQLClient.query(authLogin, { email, password }).toPromise() return response.data.signIn }, - signUp: async({ email, password }) => { + signUp: async ({ email, password }) => { const response = await publicGraphQLClient.query(authRegister, { email, password }).toPromise() return response.data.registerUser }, - signOut: async() => { + signOut: async () => { const response = await publicGraphQLClient.query(authLogout, {}).toPromise() return response.data.signOut }, @@ -170,17 +170,17 @@ export const apiClient = { const response = await publicGraphQLClient.query(authCheck, { email }).toPromise() return response.data.isEmailUsed }, - signReset: async({ email }) => { + signReset: async ({ email }) => { // send reset link with code on email const response = await publicGraphQLClient.query(authForget, { email }).toPromise() return response.data.reset }, - signResend: async({ email }) => { + signResend: async ({ email }) => { // same as reset if code is expired const response = await publicGraphQLClient.query(authResend, { email }).toPromise() return response.data.resend }, - signResetConfirm: async({ code }) => { + signResetConfirm: async ({ code }) => { // confirm reset password with code const response = await publicGraphQLClient.query(authReset, { code }).toPromise() return response.data.reset @@ -251,23 +251,17 @@ export const apiClient = { }, createReaction: async ({ reaction }) => { - const response = await privateGraphQLClient - .mutation(reactionCreate, { reaction }) - .toPromise() + const response = await privateGraphQLClient.mutation(reactionCreate, { reaction }).toPromise() log.debug('[api] create reaction mutation called') return response.data.createReaction }, updateReaction: async ({ reaction }) => { - const response = await privateGraphQLClient - .mutation(reactionUpdate, { reaction }) - .toPromise() + const response = await privateGraphQLClient.mutation(reactionUpdate, { reaction }).toPromise() return response.data.createReaction }, destroyReaction: async ({ id }) => { - const response = await privateGraphQLClient - .mutation(reactionDestroy, { id }) - .toPromise() + const response = await privateGraphQLClient.mutation(reactionDestroy, { id }).toPromise() return response.data.deleteReaction }