diff --git a/client/actions/agenda.ts b/client/actions/agenda.ts index 9e3d24398..6087d10e2 100644 --- a/client/actions/agenda.ts +++ b/client/actions/agenda.ts @@ -10,6 +10,7 @@ import {getErrorMessage, gettext, planningUtils} from '../utils'; import {planning, showModal, main} from './index'; import {convertStringFields} from '../utils/strings'; import planningApis from '../actions/planning/api'; +import eventsApis from '../actions/events/api'; const openAgenda = () => ( (dispatch) => ( @@ -311,6 +312,12 @@ const createPlanningFromEvent = ( return (dispatch) => ( dispatch(planningApis.save({}, newPlanningItem)) + .then((planningResponse) => { + return dispatch(eventsApis.fetchById(event.guid, {force: true, saveToStore: true, loadPlanning: false})) + .then(() => { + return planningResponse; + }); + }) ); }; diff --git a/client/actions/events/api.ts b/client/actions/events/api.ts index 0249c3717..649519853 100644 --- a/client/actions/events/api.ts +++ b/client/actions/events/api.ts @@ -317,7 +317,7 @@ const fetchById = (eventId, {force = false, saveToStore = true, loadPlanning = t if (has(storedEvents, eventId) && !force) { promise = Promise.resolve(storedEvents[eventId]); } else { - promise = planningApi.events.getById(eventId) + promise = planningApi.events.getById(eventId, force ? {cache: false} : undefined) .then((event) => { if (saveToStore) { dispatch(self.receiveEvents([event])); diff --git a/client/api/events.ts b/client/api/events.ts index 398f0dac1..afa944571 100644 --- a/client/api/events.ts +++ b/client/api/events.ts @@ -7,6 +7,7 @@ import { ISearchSpikeState, IPlanningConfig, IEventUpdateMethod, + IGetRequestParams, } from '../interfaces'; import {appConfig as config} from 'appConfig'; import {IRestApiResponse} from 'superdesk-api'; @@ -70,9 +71,9 @@ export function searchEventsGetAll(params: ISearchParams): Promise { +export function getEventById(eventId: IEventItem['_id'], params: IGetRequestParams): Promise { return superdeskApi.dataApi - .findOne('events', eventId) + .findOne('events', eventId + (params?.cache === false ? `?time=${Math.floor(Date.now() / 1000)}` : '')) .then(modifyItemForClient); } diff --git a/client/interfaces.ts b/client/interfaces.ts index 812e0375a..2f83eba4f 100644 --- a/client/interfaces.ts +++ b/client/interfaces.ts @@ -2186,6 +2186,10 @@ export interface IEditorAPI { }; } +export interface IGetRequestParams { + cache?: boolean; +} + export interface IPlanningAPI { redux: { store: Store; @@ -2193,7 +2197,7 @@ export interface IPlanningAPI { events: { search(params: ISearchParams): Promise>; searchGetAll(params: ISearchParams): Promise>; - getById(eventId: IEventItem['_id']): Promise; + getById(eventId: IEventItem['_id'], params?: IGetRequestParams): Promise; getByIds(eventIds: Array, spikeState?: ISearchSpikeState): Promise>; getEditorProfile(): IEventFormProfile; getSearchProfile(): IEventSearchProfile; diff --git a/client/reducers/events.ts b/client/reducers/events.ts index 3f4067f98..c737bb40f 100644 --- a/client/reducers/events.ts +++ b/client/reducers/events.ts @@ -322,7 +322,7 @@ const eventsReducer = createReducer(initialState, { [EVENTS.ACTIONS.EVENT_RECENT_TEMPLATES]: (state, payload) => ({ ...state, recentEventTemplates: payload, - }) + }), }); const onEventPostChanged = (state, payload) => {