mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-20 03:42:10 +03:00
migrated promited entries endpoint
This commit is contained in:
parent
8669a4a801
commit
7a4e4e04b0
@ -2,7 +2,7 @@ import { getAccountPosts, getRankedPosts } from "../../../providers/hive/dhive";
|
|||||||
import { filterLatestPosts, getUpdatedPosts } from "./tabbedPostsHelpers";
|
import { filterLatestPosts, getUpdatedPosts } from "./tabbedPostsHelpers";
|
||||||
import Matomo from 'react-native-matomo-sdk';
|
import Matomo from 'react-native-matomo-sdk';
|
||||||
import { LoadPostsOptions } from "./tabbedPostsModels";
|
import { LoadPostsOptions } from "./tabbedPostsModels";
|
||||||
import { getPromotePosts } from "../../../providers/ecency/ecency";
|
import { getPromotedEntries } from "../../../providers/ecency/ecency";
|
||||||
|
|
||||||
const POSTS_FETCH_COUNT = 20;
|
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 {
|
try {
|
||||||
const posts = await getPromotePosts(username);
|
const posts = await getPromotedEntries(username);
|
||||||
return Array.isArray(posts) ? posts : [];
|
return Array.isArray(posts) ? posts : [];
|
||||||
|
|
||||||
} catch(err){
|
} catch(err){
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, {useState, useEffect, useRef} from 'react';
|
import React, {useState, useEffect, useRef} from 'react';
|
||||||
import PostsList from '../../postsList';
|
import PostsList from '../../postsList';
|
||||||
import { getPromotedPosts, loadPosts } from '../services/tabbedPostsFetch';
|
import { fetchPromotedEntries, loadPosts } from '../services/tabbedPostsFetch';
|
||||||
import { LoadPostsOptions, TabContentProps, TabMeta } from '../services/tabbedPostsModels';
|
import { LoadPostsOptions, TabContentProps, TabMeta } from '../services/tabbedPostsModels';
|
||||||
import {useSelector, useDispatch } from 'react-redux';
|
import {useSelector, useDispatch } from 'react-redux';
|
||||||
import TabEmptyView from './listEmptyView';
|
import TabEmptyView from './listEmptyView';
|
||||||
@ -10,6 +10,7 @@ import { calculateTimeLeftForPostCheck } from '../services/tabbedPostsHelpers';
|
|||||||
import { AppState } from 'react-native';
|
import { AppState } from 'react-native';
|
||||||
import { PostsListRef } from '../../postsList/container/postsListContainer';
|
import { PostsListRef } from '../../postsList/container/postsListContainer';
|
||||||
|
|
||||||
|
|
||||||
const DEFAULT_TAB_META = {
|
const DEFAULT_TAB_META = {
|
||||||
startAuthor:'',
|
startAuthor:'',
|
||||||
startPermlink:'',
|
startPermlink:'',
|
||||||
@ -175,7 +176,7 @@ const TabContent = ({
|
|||||||
if(pageType === 'profile' || pageType === 'ownProfile'){
|
if(pageType === 'profile' || pageType === 'ownProfile'){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pPosts = await getPromotedPosts(username)
|
const pPosts = await fetchPromotedEntries(username)
|
||||||
if(pPosts){
|
if(pPosts){
|
||||||
setPromotedPosts(pPosts)
|
setPromotedPosts(pPosts)
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ api.interceptors.request.use((request) => {
|
|||||||
//skip code addition is register and token refresh endpoint is triggered
|
//skip code addition is register and token refresh endpoint is triggered
|
||||||
if(request.url === '/signup/account-create'
|
if(request.url === '/signup/account-create'
|
||||||
|| request.url === '/auth-api/hs-token-refresh'
|
|| request.url === '/auth-api/hs-token-refresh'
|
||||||
|
|| request.url === '/private-api/promoted-entries'
|
||||||
|| request.url.startsWith('private-api/leaderboard')
|
|| request.url.startsWith('private-api/leaderboard')
|
||||||
|
|
||||||
){
|
){
|
||||||
return request
|
return request
|
||||||
}
|
}
|
||||||
|
@ -636,6 +636,13 @@ export const uploadImage = (media, username, sign) => {
|
|||||||
|
|
||||||
export const getNodes = () => serverList.get().then((resp) => resp.data.hived || SERVER_LIST);
|
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) =>
|
export const getSCAccessToken = (code) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
ecencyApi
|
ecencyApi
|
||||||
@ -649,19 +656,28 @@ export const getSCAccessToken = (code) =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getPromotePosts = (username) => {
|
|
||||||
|
/**
|
||||||
|
* fetches promoted posts for tab content
|
||||||
|
* @param username for parsing post data
|
||||||
|
* @returns array of promoted posts
|
||||||
|
*/
|
||||||
|
export const getPromotedEntries = async (username:string) => {
|
||||||
try {
|
try {
|
||||||
console.log('Fetching promoted posts');
|
console.log('Fetching promoted entries');
|
||||||
return api.get('/promoted-posts?limit=10').then((resp) => {
|
return ecencyApi.get('/private-api/promoted-entries').then((resp) => {
|
||||||
return resp.data.map(({ post_data }) =>
|
return resp.data.map((post_data:any) =>
|
||||||
post_data ? parsePost(post_data, username, true) : null,
|
post_data ? parsePost(post_data, username, true) : null,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.warn("Failed to get promoted enties")
|
||||||
bugsnag.notify(error);
|
bugsnag.notify(error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const purchaseOrder = (data) =>
|
export const purchaseOrder = (data) =>
|
||||||
api
|
api
|
||||||
@ -678,7 +694,14 @@ export const getPostReblogs = (data) =>
|
|||||||
.catch((error) => bugsnag.notify(error));
|
.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) => {
|
export const signUp = async (username:string, email:string, referral?:string) => {
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
|
Loading…
Reference in New Issue
Block a user