import { PodcastSort } from "../api/podcastApi"; const state: ParamStore = { generalParameters: { forceOrganisationId: undefined,//"ecbd98d9-79bd-4312-ad5e-fc7c1c4a191c", forceRubriqueId: undefined, podcastmaker: false, buttonPlus: true, isLiveTab: true, isCaptchaTest: true, podcastItem: 13.5, }, podcastPage: { ShareButtons: true, mainRubrique: 0, downloadButton: false, descriptionOrSummary: 'description' }, emissionsPage: { itemPlayer: false, rubriquage: undefined, mainRubrique: undefined, buttonMore: false, progressBar: false, }, emissionPage: {}, player: { isVideoPage:false, }, searchPage: { sortCriteria: undefined, }, smartLink: { showOnlyFirstParagraphInDescription: false }, presentationItems: { tags: 'none' } }; export interface ParamStore { generalParameters: { /** Automatically filter results by this organisation */ forceOrganisationId?: string; /** Automatically filter results by these rubriques */ forceRubriqueId?: number|number[]; /** Automatically exclude these rubriquage from results */ forceNoRubriquageId?: number|number[]; /** Enable for podcastmakers */ podcastmaker?: boolean; /** Show time with the dates on podcasts */ showTimeWithDates?: boolean; buttonPlus?: boolean; /** Show the "Radio & Live" tab in the navigation; driven by additionalConfiguration from the backend */ isLiveTab?: boolean; isCaptchaTest?: boolean; podcastItem?: number; }; podcastPage: { ShareButtons?: boolean; mainRubrique?: number; downloadButton?:boolean; /** If true, hide tags on podcast page */ hideTags?: boolean; /** The maximum number of tags that can be displayed */ maxTags?: number; /** If true, do not display subtitles on podcast pages */ hideSubtitle?: boolean; /** Select whether to display description, summary, or both */ descriptionOrSummary?: 'description'|'summary'|'both'; }; emissionPage: { ShareButtons?: boolean; /** If true, hide tags on emission page */ hideTags?: boolean; /** The maximum number of tags that can be displayed */ maxTags?: number; /** If true, do not display subtitles on podcast pages */ hideSubtitle?: boolean; }; emissionsPage: { itemPlayer?: boolean; rubriquage?: number; mainRubrique?: number; buttonMore?: boolean; progressBar?: boolean; }; player: { isVideoPage?:boolean; /** * Indicates that the play is at the top of the page. * This adapts player settings for properly display. * Currently *does not* position the player. */ topPlacement?: boolean; /** Start with the large version by default */ startLarge?: boolean; /** Show a warning regarding AI generation of transcripts */ showAITranscriptWarning?: boolean; /** If true, the player will not close when finishing playing */ stayOpenOnFinish?: boolean; }; searchPage: { /** The default sort criteria for search results */ sortCriteria?: PodcastSort; }; /** Settings for presentation items */ presentationItems: { /** Type of tags to display on presentation items */ tags: 'none'|'iab'|'rubrique'; /** * For rubrique type, the ID of the rubriquage the rubriques must belong to * to be displayed. If not set, will display all rubriques. */ tagsRubriquageId?: number; /** Limit number of tags */ tagsLimit?: number; /** Additional infos displayed in presentation item */ additionalInfo?: Array<'productor'|'date'|'restrictive-rubrique'>; /** * ID of the restrictive rubriquage ID, used only when additionalInfo * contains 'restricted-rubrique' */ restrictiveRubriquageId?: number; }; /** Smartlink configuration */ smartLink: { /** Truncate the description to the first paragraph */ showOnlyFirstParagraphInDescription?: boolean; } } function definedProps(obj: Partial|undefined): Partial { if (obj === undefined) { return {}; } else { return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as Partial; } } const initialize = function initialize(initObject: Partial): void { state.generalParameters = Object.assign( state.generalParameters, definedProps(initObject.generalParameters), ); state.podcastPage = Object.assign( state.podcastPage, definedProps(initObject.podcastPage), ); state.emissionsPage = Object.assign( state.emissionsPage, definedProps(initObject.emissionsPage), ); state.emissionPage = Object.assign( state.emissionPage, definedProps(initObject.emissionPage), ); state.player = Object.assign(state.player, definedProps(initObject.player)); state.searchPage = Object.assign( state.searchPage, definedProps(initObject.searchPage), ); state.smartLink = Object.assign( state.smartLink, definedProps(initObject.smartLink) ); state.presentationItems = Object.assign( state.presentationItems, definedProps(initObject.presentationItems) ); }; export default { initialize, state }; export { initialize, state };