diff --git a/src/components/Views/Expo/Expo.tsx b/src/components/Views/Expo/Expo.tsx index 63533875..487a6c07 100644 --- a/src/components/Views/Expo/Expo.tsx +++ b/src/components/Views/Expo/Expo.tsx @@ -41,8 +41,12 @@ export const Expo = (props: Props) => { const { t } = useLocalize() + // const { sortedArticles } = useArticlesStore({ + // shouts: isLoaded() ? props.shouts : [], + // }) const { sortedArticles } = useArticlesStore({ - shouts: isLoaded() ? props.shouts : [], + shouts: props.shouts || [], + layout: props.layout, }) const getLoadShoutsFilters = (additionalFilters: LoadShoutsFilters = {}): LoadShoutsFilters => { diff --git a/src/stores/zine/articles.ts b/src/stores/zine/articles.ts index 721aca2b..c6b0de07 100644 --- a/src/stores/zine/articles.ts +++ b/src/stores/zine/articles.ts @@ -166,6 +166,7 @@ export const resetSortedArticles = () => { type InitialState = { shouts?: Shout[] + layout?: string } const TOP_MONTH_ARTICLES_COUNT = 10 @@ -203,7 +204,14 @@ export const loadTopArticles = async (): Promise => { export const useArticlesStore = (initialState: InitialState = {}) => { addArticles([...(initialState.shouts || [])]) - if (initialState.shouts) { + if (initialState.layout) { + // eslint-disable-next-line promise/catch-or-return + loadShouts({ filters: { layout: initialState.layout }, limit: 10 }).then(({ newShouts }) => { + addArticles(newShouts) + setSortedArticles(newShouts) + }) + } else if (initialState.shouts) { + addArticles([...initialState.shouts]) setSortedArticles([...initialState.shouts]) }