diff --git a/flow-typed/homepage.js b/flow-typed/homepage.js index f1696840f..9af578a24 100644 --- a/flow-typed/homepage.js +++ b/flow-typed/homepage.js @@ -12,6 +12,7 @@ declare type HomepageData = { }; declare type RowDataItem = { + id: string, title: any, link?: string, help?: any, diff --git a/ui/util/buildHomepage.js b/ui/util/buildHomepage.js index 6b4478344..cb4d0cd00 100644 --- a/ui/util/buildHomepage.js +++ b/ui/util/buildHomepage.js @@ -7,21 +7,6 @@ import moment from 'moment'; import { toCapitalCase } from 'util/string'; import { CUSTOM_HOMEPAGE } from 'config'; -export type RowDataItem = { - title: any, - link?: string, - help?: any, - icon?: string, - extra?: any, - options?: { - channelIds?: Array, - pageSize?: number, - limitClaimsPerChannel?: number, - }, - route?: string, - hideForUnauth?: boolean, -}; - export type HomepageCat = { name: string, icon: string, @@ -37,12 +22,6 @@ export type HomepageCat = { mixIn?: Array, }; -// type HomepageData = { -// [string]: { -// [string]: HomepageCat, -// }, -// }; - function getLimitPerChannel(size, isChannel) { if (isChannel) { return 1; @@ -62,7 +41,7 @@ export function getAllIds(all: any) { return Array.from(idsSet); } -export const getHomepageRowForCat = (cat: HomepageCat) => { +export const getHomepageRowForCat = (key: string, cat: HomepageCat) => { let orderValue; switch (cat.order) { case 'trending': @@ -104,6 +83,7 @@ export const getHomepageRowForCat = (cat: HomepageCat) => { } return { + id: key, link: `/$/${PAGES.DISCOVER}?${urlParams.toString()}`, route: cat.name ? `/$/${cat.name}` : undefined, icon: cat.icon || '', // some default @@ -147,6 +127,7 @@ export function GetLinksData( if (isHomepage && showPersonalizedChannels && subscribedChannels) { const RECENT_FROM_FOLLOWING = { + id: 'FOLLOWING', title: __('Recent From Following'), link: `/$/${PAGES.CHANNELS_FOLLOWING}`, icon: ICONS.SUBSCRIBE, @@ -318,6 +299,7 @@ export function GetLinksData( followedTags.forEach((tag: Tag) => { const tagName = `#${toCapitalCase(tag.name)}`; individualTagDataItems.push({ + id: tagName, title: __('Trending for %tagName%', { tagName: tagName }), link: `/$/${PAGES.DISCOVER}?t=${tag.name}`, options: { @@ -349,8 +331,14 @@ export function GetLinksData( // ************************************************************************** // TODO: provide better method for exempting from homepage - (Object.values(all): any) - .filter((row) => !(isHomepage && row.name === 'news')) - .map((row) => rowData.push(getHomepageRowForCat(row))); + const entries = Object.entries(all); + for (let i = 0; i < entries.length; ++i) { + const key = entries[i][0]; + const val = entries[i][1]; + + // $FlowFixMe https://github.com/facebook/flow/issues/2221 + rowData.push(getHomepageRowForCat(key, val)); + } + return rowData; }