Update app to use v2 homepage api
This commit is contained in:
parent
45bb9ad0fa
commit
2f6b7f0ba6
3 changed files with 25 additions and 7 deletions
|
@ -310,17 +310,31 @@ export function doFetchLanguage(language) {
|
||||||
|
|
||||||
export function doFetchHomepages() {
|
export function doFetchHomepages() {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
// -- Use this env flag to use local homepage data. Otherwise, it will grab from `/$/api/content/v1/get`.
|
// -- Use this env flag to use local homepage data. Otherwise, it will grab from `/$/api/content/v*/get`.
|
||||||
// @if USE_LOCAL_HOMEPAGE_DATA='true'
|
// @if USE_LOCAL_HOMEPAGE_DATA='true'
|
||||||
const homepages = require('homepages');
|
const homepages = require('homepages');
|
||||||
if (homepages) {
|
if (homepages) {
|
||||||
window.homepages = homepages;
|
const v2 = {};
|
||||||
|
const homepageKeys = Object.keys(homepages);
|
||||||
|
|
||||||
|
homepageKeys.forEach((hp) => {
|
||||||
|
v2[hp] = {
|
||||||
|
categories: homepages[hp],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const meme = require('memes');
|
||||||
|
if (meme && v2['en']) {
|
||||||
|
v2['en'].meme = meme;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.homepages = v2;
|
||||||
dispatch({ type: ACTIONS.FETCH_HOMEPAGES_DONE });
|
dispatch({ type: ACTIONS.FETCH_HOMEPAGES_DONE });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// @endif
|
// @endif
|
||||||
|
|
||||||
fetch('https://odysee.com/$/api/content/v1/get')
|
fetch('https://odysee.com/$/api/content/v2/get')
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
if (json?.status === 'success' && json?.data) {
|
if (json?.status === 'success' && json?.data) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ export const selectLanguage = (state) => {
|
||||||
export const selectHomepageData = (state) => {
|
export const selectHomepageData = (state) => {
|
||||||
const homepageCode = selectHomepageCode(state);
|
const homepageCode = selectHomepageCode(state);
|
||||||
const homepages = window.homepages;
|
const homepages = window.homepages;
|
||||||
return homepages ? homepages[homepageCode] || homepages['en'] || {} : {};
|
return homepages ? homepages[homepageCode].categories || homepages['en'].categories || {} : {};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const selectInRegionByCode = (state, code) => {
|
export const selectInRegionByCode = (state, code) => {
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
const memes = require('memes');
|
|
||||||
|
|
||||||
export default function Meme() {
|
export default function Meme() {
|
||||||
|
const meme = window?.homepages?.en?.meme;
|
||||||
|
if (!meme) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<h1 className="home__meme">
|
<h1 className="home__meme">
|
||||||
<Button button="link" navigate={memes.url}>
|
<Button button="link" navigate={meme.url}>
|
||||||
{memes.text}
|
{meme.text}
|
||||||
</Button>
|
</Button>
|
||||||
</h1>
|
</h1>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue