Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
fix: change api for latest articles
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsgowtham committed Aug 29, 2023
1 parent 76d65c5 commit 6adbb27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 0 additions & 10 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ export const getArticlesList = (
});
};

export const getLatestArticlesList = (
page = 1,
perPage = DEFAULT_PAGE_SIZE,
) => {
const params = buildURLParams({ page, per_page: perPage });
return axios.get(`${API_BASE_URL}/articles/latest?${params}`, {
timeout: NETWORK_TIMEOUT_MS,
});
};

export const getVideos = (page: number, perPage: number) => {
const params = buildURLParams({ page, per_page: perPage });
return axios.get(`${API_BASE_URL}/videos?${params}`, {
Expand Down
16 changes: 12 additions & 4 deletions src/store/articles/feed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getArticlesList, getLatestArticlesList } from "../../api";
import { ApiArticleFeedItem } from "../../api/types";
import { getArticlesList } from "../../api";
import { ApiArticleFeedItem, ArticleFeedApiStates } from "../../api/types";
import { perfArrayConcat } from "../../utils/array";
import { DEFAULT_PAGE_SIZE, HELP_TEXT } from "../../utils/const";
import {
Expand Down Expand Up @@ -50,7 +50,11 @@ const useArticleFeedStore = createWithEqualityFn<ArticleFeedState>()(
set((state) => ({ ...state, latest: setFetchingState(state.latest) }));

try {
const response = await getLatestArticlesList(page, DEFAULT_PAGE_SIZE);
const response = await getArticlesList(
ArticleFeedApiStates.Fresh,
page,
DEFAULT_PAGE_SIZE,
);
const responseArticles: ApiArticleFeedItem[] = await response.data;
set((state) => ({
...state,
Expand All @@ -76,7 +80,11 @@ const useArticleFeedStore = createWithEqualityFn<ArticleFeedState>()(
}));

try {
const response = await getLatestArticlesList(1, 10);
const response = await getArticlesList(
ArticleFeedApiStates.Fresh,
1,
10,
);

const articles: ApiArticleFeedItem[] = await response.data;
set((state) => ({
Expand Down

0 comments on commit 6adbb27

Please sign in to comment.