diff --git a/client/package.json b/client/package.json index 199538d85..ecde8d3ae 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "ontime-ui", - "version": "1.8.4", + "version": "1.8.5", "private": true, "dependencies": { "@chakra-ui/react": "^2.3.2", diff --git a/client/src/common/api/apiConstants.js b/client/src/common/api/apiConstants.js index a6d3a5064..b641cbaa8 100644 --- a/client/src/common/api/apiConstants.js +++ b/client/src/common/api/apiConstants.js @@ -2,7 +2,8 @@ export const STATIC_PORT = 4001; export const EVENT_TABLE = ['event']; export const ALIASES = ['aliases']; export const USERFIELDS = ['userFields']; -export const EVENTS_TABLE = ['events']; +export const EVENTS_TABLE_KEY = 'events'; +export const EVENTS_TABLE = [EVENTS_TABLE_KEY]; export const APP_TABLE = ['appinfo']; export const OSC_SETTINGS = ['oscSettings']; export const APP_SETTINGS = ['appSettings']; diff --git a/client/src/features/editors/list/EventListWrapper.jsx b/client/src/features/editors/list/EventListWrapper.jsx index fea78f725..5314617cf 100644 --- a/client/src/features/editors/list/EventListWrapper.jsx +++ b/client/src/features/editors/list/EventListWrapper.jsx @@ -1,6 +1,6 @@ import { useCallback, useContext, useEffect, useState } from 'react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { EVENTS_TABLE } from 'common/api/apiConstants'; +import { EVENTS_TABLE, EVENTS_TABLE_KEY } from 'common/api/apiConstants'; import { fetchAllEvents, requestApplyDelay, @@ -79,13 +79,13 @@ export default function EventListWrapper() { // we optimistically update here onMutate: async (newEvent) => { // cancel ongoing queries - queryClient.cancelQueries([EVENTS_TABLE, newEvent.id]); + queryClient.cancelQueries([EVENTS_TABLE_KEY, newEvent.id]); // Snapshot the previous value - const previousEvent = queryClient.getQueryData([EVENTS_TABLE, newEvent.id]); + const previousEvent = queryClient.getQueryData([EVENTS_TABLE_KEY, newEvent.id]); // optimistically update object - queryClient.setQueryData([EVENTS_TABLE, newEvent.id], newEvent); + queryClient.setQueryData([EVENTS_TABLE_KEY, newEvent.id], newEvent); // Return a context with the previous and new todo return { previousEvent, newEvent }; @@ -93,12 +93,12 @@ export default function EventListWrapper() { // Mutation fails, rollback undos optimist update onError: (error, newEvent, context) => { - queryClient.setQueryData([EVENTS_TABLE, context.newEvent.id], context.previousEvent); + queryClient.setQueryData([EVENTS_TABLE_KEY, context.newEvent.id], context.previousEvent); }, // Mutation finished, failed or successful // Fetch anyway, just to be sure onSettled: (newEvent) => { - queryClient.invalidateQueries([EVENTS_TABLE, newEvent.id]); + queryClient.invalidateQueries([EVENTS_TABLE_KEY, newEvent.id]); }, }); @@ -106,13 +106,13 @@ export default function EventListWrapper() { // we optimistically update here onMutate: async (newEvent) => { // cancel ongoing queries - queryClient.cancelQueries([EVENTS_TABLE, newEvent.id]); + queryClient.cancelQueries([EVENTS_TABLE_KEY, newEvent.id]); // Snapshot the previous value - const previousEvent = queryClient.getQueryData([EVENTS_TABLE, newEvent.id]); + const previousEvent = queryClient.getQueryData([EVENTS_TABLE_KEY, newEvent.id]); // optimistically update object - queryClient.setQueryData([EVENTS_TABLE, newEvent.id], newEvent); + queryClient.setQueryData([EVENTS_TABLE_KEY, newEvent.id], newEvent); // Return a context with the previous and new todo return { previousEvent, newEvent }; @@ -120,13 +120,13 @@ export default function EventListWrapper() { // Mutation fails, rollback undos optimist update onError: (error, newEvent, context) => { - queryClient.setQueryData([EVENTS_TABLE, context.newEvent.id], context.previousEvent); + queryClient.setQueryData([EVENTS_TABLE_KEY, context.newEvent.id], context.previousEvent); }, // Mutation finished, failed or successful // Fetch anyway, just to be sure onSettled: (newEvent) => { if (newEvent) { - queryClient.invalidateQueries([EVENTS_TABLE, newEvent.id]); + queryClient.invalidateQueries([EVENTS_TABLE_KEY, newEvent.id]); } else { queryClient.invalidateQueries(EVENTS_TABLE); } @@ -137,7 +137,7 @@ export default function EventListWrapper() { // we optimistically update here onMutate: async (eventId) => { // cancel ongoing queries - queryClient.cancelQueries([EVENTS_TABLE, eventId]); + queryClient.cancelQueries([EVENTS_TABLE_KEY, eventId]); // Snapshot the previous value const previousEvents = queryClient.getQueryData(EVENTS_TABLE); diff --git a/server/package.json b/server/package.json index f735e15d6..6755a72d6 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "ontime", - "version": "1.8.4", + "version": "1.8.5", "author": "Carlos Valente", "description": "Time keeping for live events", "repository": "https://github.com/cpvalente/ontime",