diff --git a/src/components/tabbedPosts/services/tabbedPostsFetch.ts b/src/components/tabbedPosts/services/tabbedPostsFetch.ts index a6b864ba9..b4e6995cf 100644 --- a/src/components/tabbedPosts/services/tabbedPostsFetch.ts +++ b/src/components/tabbedPosts/services/tabbedPostsFetch.ts @@ -2,7 +2,7 @@ import { getAccountPosts, getRankedPosts } from "../../../providers/hive/dhive"; import { filterLatestPosts, getUpdatedPosts } from "./tabbedPostsHelpers"; import Matomo from 'react-native-matomo-sdk'; import { LoadPostsOptions } from "./tabbedPostsModels"; -import { getPromotePosts } from "../../../providers/ecency/ecency"; +import { getPromotedEntries } from "../../../providers/ecency/ecency"; const POSTS_FETCH_COUNT = 20; @@ -170,9 +170,9 @@ export const loadPosts = async ({ - export const getPromotedPosts = async (username:string) => { + export const fetchPromotedEntries = async (username:string) => { try { - const posts = await getPromotePosts(username); + const posts = await getPromotedEntries(username); return Array.isArray(posts) ? posts : []; } catch(err){ diff --git a/src/components/tabbedPosts/view/tabContent.tsx b/src/components/tabbedPosts/view/tabContent.tsx index 3fc26957c..b4e303af9 100644 --- a/src/components/tabbedPosts/view/tabContent.tsx +++ b/src/components/tabbedPosts/view/tabContent.tsx @@ -1,6 +1,6 @@ import React, {useState, useEffect, useRef} from 'react'; import PostsList from '../../postsList'; -import { getPromotedPosts, loadPosts } from '../services/tabbedPostsFetch'; +import { fetchPromotedEntries, loadPosts } from '../services/tabbedPostsFetch'; import { LoadPostsOptions, TabContentProps, TabMeta } from '../services/tabbedPostsModels'; import {useSelector, useDispatch } from 'react-redux'; import TabEmptyView from './listEmptyView'; @@ -10,6 +10,7 @@ import { calculateTimeLeftForPostCheck } from '../services/tabbedPostsHelpers'; import { AppState } from 'react-native'; import { PostsListRef } from '../../postsList/container/postsListContainer'; + const DEFAULT_TAB_META = { startAuthor:'', startPermlink:'', @@ -175,7 +176,7 @@ const TabContent = ({ if(pageType === 'profile' || pageType === 'ownProfile'){ return; } - const pPosts = await getPromotedPosts(username) + const pPosts = await fetchPromotedEntries(username) if(pPosts){ setPromotedPosts(pPosts) } diff --git a/src/config/ecencyApi.ts b/src/config/ecencyApi.ts index 2b16e324d..484ce0e5e 100644 --- a/src/config/ecencyApi.ts +++ b/src/config/ecencyApi.ts @@ -20,8 +20,8 @@ api.interceptors.request.use((request) => { //skip code addition is register and token refresh endpoint is triggered if(request.url === '/signup/account-create' || request.url === '/auth-api/hs-token-refresh' + || request.url === '/private-api/promoted-entries' || request.url.startsWith('private-api/leaderboard') - ){ return request } diff --git a/src/providers/ecency/ecency.ts b/src/providers/ecency/ecency.ts index 012080920..cbf438e34 100644 --- a/src/providers/ecency/ecency.ts +++ b/src/providers/ecency/ecency.ts @@ -636,6 +636,13 @@ export const uploadImage = (media, username, sign) => { export const getNodes = () => serverList.get().then((resp) => resp.data.hived || SERVER_LIST); + + +/** + * refreshes access token using refresh token + * @param code refresh token + * @returns scToken (includes accessToken as property) + */ export const getSCAccessToken = (code) => new Promise((resolve, reject) => { ecencyApi @@ -649,19 +656,28 @@ export const getSCAccessToken = (code) => }); }); -export const getPromotePosts = (username) => { - try { - console.log('Fetching promoted posts'); - return api.get('/promoted-posts?limit=10').then((resp) => { - return resp.data.map(({ post_data }) => - post_data ? parsePost(post_data, username, true) : null, - ); - }); - } catch (error) { - bugsnag.notify(error); - return error; - } -}; + + /** + * fetches promoted posts for tab content + * @param username for parsing post data + * @returns array of promoted posts + */ + export const getPromotedEntries = async (username:string) => { + try { + console.log('Fetching promoted entries'); + return ecencyApi.get('/private-api/promoted-entries').then((resp) => { + return resp.data.map((post_data:any) => + post_data ? parsePost(post_data, username, true) : null, + ); + }); + } catch (error) { + console.warn("Failed to get promoted enties") + bugsnag.notify(error); + return error; + } + }; + + export const purchaseOrder = (data) => api @@ -678,7 +694,14 @@ export const getPostReblogs = (data) => .catch((error) => bugsnag.notify(error)); - +/** + * Registers new user with ecency and hive, on confirmation sends + * details to user email + * @param username for new user + * @param email of new user + * @param referral username + * @returns boolean success flag + */ export const signUp = async (username:string, email:string, referral?:string) => { try { const data = {