@ynput/ayon-frontend-shared 0.3.26 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.cjs14.js +1 -1
- package/dist/_virtual/index.cjs15.js +1 -1
- package/dist/_virtual/index.cjs19.js +1 -1
- package/dist/_virtual/index.cjs22.js +1 -1
- package/dist/_virtual/index.cjs23.js +1 -1
- package/dist/_virtual/index.cjs24.js +1 -1
- package/dist/_virtual/index.cjs4.js +1 -1
- package/dist/_virtual/index.cjs5.js +1 -1
- package/dist/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es10.js +2 -2
- package/dist/_virtual/index.es11.js +2 -2
- package/dist/_virtual/index.es13.js +2 -2
- package/dist/_virtual/index.es14.js +2 -2
- package/dist/_virtual/index.es15.js +2 -2
- package/dist/_virtual/index.es16.js +2 -2
- package/dist/_virtual/index.es17.js +2 -2
- package/dist/_virtual/index.es18.js +2 -2
- package/dist/_virtual/index.es19.js +2 -2
- package/dist/_virtual/index.es22.js +3 -3
- package/dist/_virtual/index.es23.js +5 -5
- package/dist/_virtual/index.es24.js +5 -5
- package/dist/_virtual/index.es4.js +5 -2
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/_virtual/index.es5.js +2 -5
- package/dist/_virtual/index.es5.js.map +1 -1
- package/dist/_virtual/index.es8.js +2 -5
- package/dist/_virtual/index.es8.js.map +1 -1
- package/dist/_virtual/index.es9.js +5 -2
- package/dist/_virtual/index.es9.js.map +1 -1
- package/dist/node_modules/match-sorter/dist/match-sorter.esm.cjs.js +1 -1
- package/dist/node_modules/match-sorter/dist/match-sorter.esm.es.js +1 -1
- package/dist/node_modules/rehype/node_modules/unified/lib/index.cjs.js +1 -1
- package/dist/node_modules/rehype/node_modules/unified/lib/index.es.js +2 -2
- package/dist/node_modules/rehype/node_modules/vfile/lib/index.cjs.js +1 -1
- package/dist/node_modules/rehype/node_modules/vfile/lib/index.es.js +1 -1
- package/dist/node_modules/rehype-parse/lib/index.cjs.js +1 -1
- package/dist/node_modules/rehype-parse/lib/index.es.js +1 -1
- package/dist/node_modules/remove-accents/index.cjs.js +1 -1
- package/dist/node_modules/remove-accents/index.cjs.js.map +1 -1
- package/dist/node_modules/remove-accents/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime/dist/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime/dist/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/module/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/module/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/plugins/snapshot/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/plugins/snapshot/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/remote/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/remote/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/shared/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/shared/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/type/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/type/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/hooks/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/hooks/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/semver/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/semver/index.cjs.js.map +1 -1
- package/dist/shared/node_modules/@module-federation/runtime-core/dist/utils/semver/index.es.js +1 -1
- package/dist/shared/node_modules/@module-federation/sdk/dist/index.cjs.js +1 -1
- package/dist/shared/node_modules/@module-federation/sdk/dist/index.es.js +1 -1
- package/dist/shared/node_modules/prop-types/index.cjs.js +1 -1
- package/dist/shared/node_modules/prop-types/index.es.js +1 -1
- package/dist/shared/node_modules/react-transition-group/esm/CSSTransition.cjs.js +1 -1
- package/dist/shared/node_modules/react-transition-group/esm/CSSTransition.es.js +1 -1
- package/dist/shared/node_modules/react-transition-group/esm/Transition.cjs.js +1 -1
- package/dist/shared/node_modules/react-transition-group/esm/Transition.es.js +1 -1
- package/dist/shared/node_modules/react-transition-group/esm/utils/PropTypes.cjs.js +1 -1
- package/dist/shared/node_modules/react-transition-group/esm/utils/PropTypes.es.js +1 -1
- package/dist/shared/src/components/RemotePage/RemotePageWrapper.cjs.js +1 -1
- package/dist/shared/src/components/RemotePage/RemotePageWrapper.cjs.js.map +1 -1
- package/dist/shared/src/components/RemotePage/RemotePageWrapper.es.js +16 -16
- package/dist/shared/src/components/RemotePage/RemotePageWrapper.es.js.map +1 -1
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.cjs.js +1 -1
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.es.js +29 -24
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.es.js.map +1 -1
- package/dist/types/containers/Views/utils/viewUpdateHelper.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../api/base/client.cjs.js");require("../../../api/generated/graphql.cjs.js");require("../../../api/generated/graphqlLinks.cjs.js");require("../../../api/generated/access.cjs.js");require("../../../api/generated/actions.cjs.js");require("../../../api/generated/activityFeed.cjs.js");require("../../../api/generated/addons.cjs.js");require("../../../api/generated/anatomy.cjs.js");require("../../../api/generated/attributes.cjs.js");require("../../../api/generated/authentication.cjs.js");require("../../../api/generated/bundles.cjs.js");require("../../../api/generated/configuration.cjs.js");require("../../../api/generated/dataImport.cjs.js");require("../../../api/generated/desktop.cjs.js");require("../../../api/generated/entityLists.cjs.js");require("../../../api/generated/events.cjs.js");require("../../../api/generated/files.cjs.js");require("../../../api/generated/folders.cjs.js");require("../../../api/generated/inbox.cjs.js");require("../../../api/generated/links.cjs.js");require("../../../api/generated/market.cjs.js");require("../../../api/generated/onboarding.cjs.js");require("../../../api/generated/operations.cjs.js");require("../../../api/generated/products.cjs.js");require("../../../api/generated/projectDashboard.cjs.js");require("../../../api/generated/projects.cjs.js");require("../../../api/generated/projectFolders.cjs.js");require("../../../api/generated/reviewables.cjs.js");require("../../../api/generated/services.cjs.js");require("../../../api/generated/system.cjs.js");require("../../../api/generated/tasks.cjs.js");require("../../../api/generated/teams.cjs.js");require("../../../api/generated/thumbnails.cjs.js");require("../../../api/generated/uRIs.cjs.js");require("../../../api/generated/users.cjs.js");require("../../../api/generated/versions.cjs.js");require("../../../api/generated/workfiles.cjs.js");require("../../../api/generated/ynputCloud.cjs.js");require("../../../api/generated/grouping.cjs.js");require("../../../api/generated/views.cjs.js");require("../../../api/queries/actions/getActions.cjs.js");require("../../../api/queries/activities/getActivities.cjs.js");require("../../../api/queries/activities/updateActivities.cjs.js");require("../../../api/queries/activities/updateReaction.cjs.js");require("../../../api/queries/activities/getMentions.cjs.js");require("../../../api/queries/activities/getCategories.cjs.js");require("../../../api/queries/addons/getAddons.cjs.js");require("../../../api/queries/addons/updateAddons.cjs.js");require("../../../api/queries/attributes/getAttributes.cjs.js");require("../../../api/queries/attributes/updateAttributes.cjs.js");require("../../../api/queries/authentication/getAuthentication.cjs.js");require("../../../api/queries/cloud/cloud.cjs.js");require("../../../api/queries/config/getConfig.cjs.js");require("../../../api/queries/config/updateConfig.cjs.js");require("../../../api/queries/entities/getEntity.cjs.js");require("../../../api/queries/entities/getEntityPanel.cjs.js");require("../../../api/queries/entities/updateEntity.cjs.js");require("../../../api/queries/entityLists/getLists.cjs.js");require("../../../api/queries/entityLists/updateLists.cjs.js");require("../../../api/queries/entityLists/getListsAttributes.cjs.js");require("../../../api/queries/entityLists/updateListsAttributes.cjs.js");require("../../../api/queries/entityLists/listFolders.cjs.js");require("../../../api/queries/folders/getFolders.cjs.js");require("../../../api/queries/grouping/getGrouping.cjs.js");require("../../../api/queries/links/updateLinks.cjs.js");require("../../../api/queries/links/getLinks.cjs.js");require("../../../api/queries/links/getEntityLinks.cjs.js");require("../../../api/queries/overview/getOverview.cjs.js");require("../../../api/queries/overview/updateOverview.cjs.js");require("../../../api/queries/versions/getVersionsProducts.cjs.js");require("../../../api/queries/permissions/getPermissions.cjs.js");require("../../../api/queries/products/createProduct.cjs.js");require("../../../api/queries/products/getFolderProducts.cjs.js");require("../../../api/queries/project/getProject.cjs.js");require("../../../api/queries/project/updateProject.cjs.js");require("../../../api/queries/projectFolders/projectFolders.cjs.js");require("../../../api/queries/review/getReview.cjs.js");require("../../../api/queries/review/updateReview.cjs.js");require("../../../api/queries/share/share.cjs.js");require("../../../api/queries/system/getSystem.cjs.js");require("../../../api/queries/tasks/getTasks.cjs.js");require("../../../api/queries/tasks/updateTasks.cjs.js");require("../../../api/queries/teams/getTeams.cjs.js");require("../../../api/queries/userDashboard/getUserDashboard.cjs.js");require("../../../api/queries/users/getUsers.cjs.js");require("../../../api/queries/users/updateUsers.cjs.js");require("../../../api/queries/users/guests.cjs.js");require("../../../api/queries/versions/updateVersions.cjs.js");require("../../../api/queries/views/getViews.cjs.js");const g=require("../../../api/queries/views/updateViews.cjs.js");require("../../../api/queries/watchers/getWatchers.cjs.js");require("../../../api/queries/uris/getUris.cjs.js");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../api/base/client.cjs.js");require("../../../api/generated/graphql.cjs.js");require("../../../api/generated/graphqlLinks.cjs.js");require("../../../api/generated/access.cjs.js");require("../../../api/generated/actions.cjs.js");require("../../../api/generated/activityFeed.cjs.js");require("../../../api/generated/addons.cjs.js");require("../../../api/generated/anatomy.cjs.js");require("../../../api/generated/attributes.cjs.js");require("../../../api/generated/authentication.cjs.js");require("../../../api/generated/bundles.cjs.js");require("../../../api/generated/configuration.cjs.js");require("../../../api/generated/dataImport.cjs.js");require("../../../api/generated/desktop.cjs.js");require("../../../api/generated/entityLists.cjs.js");require("../../../api/generated/events.cjs.js");require("../../../api/generated/files.cjs.js");require("../../../api/generated/folders.cjs.js");require("../../../api/generated/inbox.cjs.js");require("../../../api/generated/links.cjs.js");require("../../../api/generated/market.cjs.js");require("../../../api/generated/onboarding.cjs.js");require("../../../api/generated/operations.cjs.js");require("../../../api/generated/products.cjs.js");require("../../../api/generated/projectDashboard.cjs.js");require("../../../api/generated/projects.cjs.js");require("../../../api/generated/projectFolders.cjs.js");require("../../../api/generated/reviewables.cjs.js");require("../../../api/generated/services.cjs.js");require("../../../api/generated/system.cjs.js");require("../../../api/generated/tasks.cjs.js");require("../../../api/generated/teams.cjs.js");require("../../../api/generated/thumbnails.cjs.js");require("../../../api/generated/uRIs.cjs.js");require("../../../api/generated/users.cjs.js");require("../../../api/generated/versions.cjs.js");require("../../../api/generated/workfiles.cjs.js");require("../../../api/generated/ynputCloud.cjs.js");require("../../../api/generated/grouping.cjs.js");require("../../../api/generated/views.cjs.js");require("../../../api/queries/actions/getActions.cjs.js");require("../../../api/queries/activities/getActivities.cjs.js");require("../../../api/queries/activities/updateActivities.cjs.js");require("../../../api/queries/activities/updateReaction.cjs.js");require("../../../api/queries/activities/getMentions.cjs.js");require("../../../api/queries/activities/getCategories.cjs.js");require("../../../api/queries/addons/getAddons.cjs.js");require("../../../api/queries/addons/updateAddons.cjs.js");require("../../../api/queries/attributes/getAttributes.cjs.js");require("../../../api/queries/attributes/updateAttributes.cjs.js");require("../../../api/queries/authentication/getAuthentication.cjs.js");require("../../../api/queries/cloud/cloud.cjs.js");require("../../../api/queries/config/getConfig.cjs.js");require("../../../api/queries/config/updateConfig.cjs.js");require("../../../api/queries/entities/getEntity.cjs.js");require("../../../api/queries/entities/getEntityPanel.cjs.js");require("../../../api/queries/entities/updateEntity.cjs.js");require("../../../api/queries/entityLists/getLists.cjs.js");require("../../../api/queries/entityLists/updateLists.cjs.js");require("../../../api/queries/entityLists/getListsAttributes.cjs.js");require("../../../api/queries/entityLists/updateListsAttributes.cjs.js");require("../../../api/queries/entityLists/listFolders.cjs.js");require("../../../api/queries/folders/getFolders.cjs.js");require("../../../api/queries/grouping/getGrouping.cjs.js");require("../../../api/queries/links/updateLinks.cjs.js");require("../../../api/queries/links/getLinks.cjs.js");require("../../../api/queries/links/getEntityLinks.cjs.js");require("../../../api/queries/overview/getOverview.cjs.js");require("../../../api/queries/overview/updateOverview.cjs.js");require("../../../api/queries/versions/getVersionsProducts.cjs.js");require("../../../api/queries/permissions/getPermissions.cjs.js");require("../../../api/queries/products/createProduct.cjs.js");require("../../../api/queries/products/getFolderProducts.cjs.js");require("../../../api/queries/project/getProject.cjs.js");require("../../../api/queries/project/updateProject.cjs.js");require("../../../api/queries/projectFolders/projectFolders.cjs.js");require("../../../api/queries/review/getReview.cjs.js");require("../../../api/queries/review/updateReview.cjs.js");require("../../../api/queries/share/share.cjs.js");require("../../../api/queries/system/getSystem.cjs.js");require("../../../api/queries/tasks/getTasks.cjs.js");require("../../../api/queries/tasks/updateTasks.cjs.js");require("../../../api/queries/teams/getTeams.cjs.js");require("../../../api/queries/userDashboard/getUserDashboard.cjs.js");require("../../../api/queries/users/getUsers.cjs.js");require("../../../api/queries/users/updateUsers.cjs.js");require("../../../api/queries/users/guests.cjs.js");require("../../../api/queries/versions/updateVersions.cjs.js");require("../../../api/queries/views/getViews.cjs.js");const g=require("../../../api/queries/views/updateViews.cjs.js");require("../../../api/queries/watchers/getWatchers.cjs.js");require("../../../api/queries/uris/getUris.cjs.js");const j=require("./generateWorkingView.cjs.js"),C=require("react-toastify"),V=require("react"),N=require("react-redux"),x=require("../context/ViewsContext.cjs.js");let d=!1;const M=()=>{d||(d=!0,queueMicrotask(()=>{d=!1}))},T=async(o,i,t,u={},n,a,y,e)=>{const{viewSettings:s,viewType:q,projectName:f,selectedView:r,setSelectedView:v,workingView:m,onSettingsChanged:S}=n;if(!q)throw new Error("No view type provided for updating view settings");const k=r?.id,h=r?.working;try{i(t);const c={...y()??s,...o},l=j.generateWorkingView(c),w=m?.id;w&&(l.id=w);const b=l.id,W=a({payload:w?{settings:c}:l,viewType:q,projectName:f},w);e(),h||(r&&S(!0),v(b)),await W,i(null),u.successMessage&&C.toast.success(u.successMessage)}catch(p){i(null),k&&v(k),r&&!h&&S(!1),console.error(p);const c=u.errorMessage||`Failed to update view settings: ${p}`;C.toast.error(c)}},H=()=>{const[o]=g.useCreateViewMutation(),[i]=g.useUpdateViewMutation(),t=x.useViewsContext(),u=N.useStore(),n=V.useCallback(async(e,s)=>{if(s){const q={};return["label","owner","settings"].forEach(r=>{e.payload[r]!==void 0&&(q[r]=e.payload[r])}),await i({viewType:e.viewType,projectName:e.projectName,viewId:s,payload:q}).unwrap()}else return await o(e).unwrap()},[o,i]),a=V.useCallback(()=>{if(!d)return;const{viewType:e,projectName:s}=t;return e?g.viewsQueries.endpoints.getWorkingView.select({viewType:e,projectName:s})(u.getState())?.data?.settings:void 0},[u,t]);return{updateViewSettings:V.useCallback(async(...e)=>await T(...e,t,n,a,M),[t,n,a]),onCreateView:n,getLatestSettings:a,markCacheDirty:M}};exports.updateViewSettings=T;exports.useViewUpdateHelper=H;
|
|
2
2
|
//# sourceMappingURL=viewUpdateHelper.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewUpdateHelper.cjs.js","sources":["../../../../../../src/containers/Views/utils/viewUpdateHelper.ts"],"sourcesContent":["/**\n * Shared helper for updating view settings with optimistic local state management.\n *\n * Sequential updateViewSettings calls in the same event tick MUST chain correctly:\n * the second call has to see the first call's changes. Closure-captured\n * `viewSettings` does not refresh between sync calls (no re-render yet), so we\n * read the latest settings from the RTK Query cache at call time instead.\n * RTK's updateView mutation performs an optimistic cache write in\n * `onQueryStarted`, so the cache is already up-to-date by the time the next\n * call reads it.\n */\n\nimport {\n CreateViewApiArg,\n EntityIdResponse,\n useCreateViewMutation,\n useUpdateViewMutation,\n viewsQueries,\n} from '@shared/api'\nimport { generateWorkingView } from './generateWorkingView'\nimport { toast } from 'react-toastify'\nimport { useCallback } from 'react'\nimport { useStore } from 'react-redux'\nimport { useViewsContext, ViewsContextValue, ViewSettings } from '../context/ViewsContext'\n\ninterface UpdateOptions {\n successMessage?: string\n errorMessage?: string\n}\n\n// Module-level flag shared across every useViewUpdateHelper instance. Set true\n// when a mutation has been dispatched in the current tick (RTK cache is now\n// optimistically fresh); reset on the next microtask. Must be module-level so\n// that two different hook instances (e.g. ProjectOverviewDataProvider +\n// ProjectOverviewContext) coordinate correctly when writes flow through one\n// and subsequent reads come from the other in the same event tick.\nlet cacheDirtyThisTick = false\nconst markCacheDirty = () => {\n if (cacheDirtyThisTick) return\n cacheDirtyThisTick = true\n queueMicrotask(() => {\n cacheDirtyThisTick = false\n })\n}\n\nexport type UpdateViewSettingsFn = (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions,\n) => Promise<void>\n\nexport const updateViewSettings = async (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions = {},\n viewContext: ViewsContextValue,\n onApplyViewChanges: (arg: any, viewId?: string) => Promise<EntityIdResponse | void>,\n // Reads latest effective settings from RTK Query cache at call time. Required to\n // prevent stale-closure races when two updates fire in the same tick.\n getLatestSettings: () => ViewSettings | undefined,\n // Invoked synchronously right after the mutation is dispatched. The caller\n // uses this to flip a \"cache is fresh this tick\" flag so subsequent sync\n // calls in the same tick read the just-updated cache instead of stale state.\n markCacheDirty: () => void,\n): Promise<void> => {\n const {\n viewSettings,\n viewType,\n projectName,\n selectedView,\n setSelectedView,\n workingView,\n onSettingsChanged,\n } = viewContext\n\n if (!viewType) throw new Error('No view type provided for updating view settings')\n\n const previousSelectedViewId = selectedView?.id\n const wasWorking = selectedView?.working\n\n try {\n // Immediately update local state for fast UI response\n localStateSetter(newLocalValue)\n\n // Read latest settings from RTK cache (includes prior same-tick optimistic writes).\n // Fallback to closure-captured value if cache has nothing (first render, etc.).\n const latestSettings = getLatestSettings() ?? viewSettings\n\n // Create settings with updates\n const newSettings = { ...latestSettings, ...updatedSettings }\n\n // always update the working view no matter what\n const newWorkingView = generateWorkingView(newSettings)\n\n // Ensure the payload uses the consistent ID if we already have a working view\n const viewId = workingView?.id\n if (viewId) {\n newWorkingView.id = viewId\n }\n const newWorkingViewId = newWorkingView.id\n\n // Make API call in background\n // only include the fields that are updating (just settings)\n const payload = viewId ? { settings: newSettings } : newWorkingView\n\n const promise = onApplyViewChanges(\n {\n payload,\n viewType: viewType,\n projectName: projectName,\n },\n viewId,\n )\n\n // Mutation dispatch above ran onQueryStarted synchronously → RTK cache now\n // reflects `newSettings`. Signal this so any subsequent sync call in the\n // same tick reads the fresh cache instead of the stale closure baseline.\n markCacheDirty()\n\n // if not already on the working view: set that the settings have been changed to show the little blue save button and switch to the working view\n if (!wasWorking) {\n if (selectedView) {\n onSettingsChanged(true)\n }\n setSelectedView(newWorkingViewId as string)\n }\n\n await promise\n\n // Clear local state after successful API call - the server data will take over\n localStateSetter(null)\n\n if (options.successMessage) {\n toast.success(options.successMessage)\n }\n } catch (error) {\n // Revert local state on error\n localStateSetter(null)\n\n if (previousSelectedViewId) {\n setSelectedView(previousSelectedViewId)\n }\n\n if (selectedView && !wasWorking) {\n onSettingsChanged(false)\n }\n\n console.error(error)\n const errorMsg = options.errorMessage || `Failed to update view settings: ${error}`\n toast.error(errorMsg)\n }\n}\n\nexport const useViewUpdateHelper = () => {\n const [createView] = useCreateViewMutation()\n const [updateView] = useUpdateViewMutation()\n\n const viewContext = useViewsContext()\n const store = useStore()\n\n const onApplyViewChanges = useCallback(\n async (arg: any, viewId?: string) => {\n if (viewId) {\n // Filter the payload to only include valid patch fields\n // and ideally only include fields that are actually being updated.\n // Expecting the caller to provide only the fields they want to update in the payload.\n const patchPayload: any = {}\n const patchFields = ['label', 'owner', 'settings']\n patchFields.forEach((key) => {\n if (arg.payload[key] !== undefined) {\n patchPayload[key] = arg.payload[key]\n }\n })\n\n return await updateView({\n viewType: arg.viewType,\n projectName: arg.projectName,\n viewId,\n payload: patchPayload,\n }).unwrap()\n } else {\n return await createView(arg).unwrap()\n }\n },\n [createView, updateView],\n )\n\n // Returns cached settings when a same-tick prior write has refreshed the\n // cache. Otherwise returns undefined and the caller falls back to the\n // closure-captured viewSettings (correct baseline for the first write in a\n // tick, including the named-view → working-view fork).\n const getLatestSettings = useCallback((): ViewSettings | undefined => {\n if (!cacheDirtyThisTick) return undefined\n const { viewType, projectName } = viewContext\n if (!viewType) return undefined\n // RTK selector state is typed against the full RootState; we don't have that\n // type in @shared and the store is project-specific. Cast is safe: the\n // selector only touches the api slice, which exists in every consumer app.\n const entry = viewsQueries.endpoints.getWorkingView.select({ viewType, projectName })(\n store.getState() as any,\n )\n return entry?.data?.settings\n }, [store, viewContext])\n\n const updateViewSettingsHandler = useCallback<UpdateViewSettingsFn>(\n async (...args) =>\n await updateViewSettings(\n ...args,\n viewContext,\n onApplyViewChanges,\n getLatestSettings,\n markCacheDirty,\n ),\n [viewContext, onApplyViewChanges, getLatestSettings],\n )\n\n return { updateViewSettings: updateViewSettingsHandler, onCreateView: onApplyViewChanges }\n}\n"],"names":["cacheDirtyThisTick","markCacheDirty","updateViewSettings","updatedSettings","localStateSetter","newLocalValue","options","viewContext","onApplyViewChanges","getLatestSettings","viewSettings","viewType","projectName","selectedView","setSelectedView","workingView","onSettingsChanged","previousSelectedViewId","wasWorking","newSettings","newWorkingView","generateWorkingView","viewId","newWorkingViewId","promise","toast","error","errorMsg","useViewUpdateHelper","createView","useCreateViewMutation","updateView","useUpdateViewMutation","useViewsContext","store","useStore","useCallback","arg","patchPayload","key","viewsQueries","args"],"mappings":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EfzB,EAAc0B,EAAAA,gBAAA,EACdC,EAAQC,EAAAA,SAAA,EAER3B,EAAqB4B,EAAAA,YACzB,MAAOC,EAAUf,IAAoB,CACnC,GAAIA,EAAQ,CAIV,MAAMgB,EAAoB,CAAA,EAE1B,MADoB,CAAC,QAAS,QAAS,UAAU,EACrC,QAASC,GAAQ,CACvBF,EAAI,QAAQE,CAAG,IAAM,SACvBD,EAAaC,CAAG,EAAIF,EAAI,QAAQE,CAAG,EAEvC,CAAC,EAEM,MAAMR,EAAW,CACtB,SAAUM,EAAI,SACd,YAAaA,EAAI,YACjB,OAAAf,EACA,QAASgB,CAAA,CACV,EAAE,OAAA,CACL,KACE,QAAO,MAAMT,EAAWQ,CAAG,EAAE,OAAA,CAEjC,EACA,CAACR,EAAYE,CAAU,CAAA,EAOnBtB,EAAoB2B,EAAAA,YAAY,IAAgC,CACpE,GAAI,CAACpC,EAAoB,OACzB,KAAM,CAAE,SAAAW,EAAU,YAAAC,CAAA,EAAgBL,EAClC,OAAKI,EAIS6B,EAAAA,aAAa,UAAU,eAAe,OAAO,CAAE,SAAA7B,EAAU,YAAAC,EAAa,EAClFsB,EAAM,SAAA,CAAS,GAEH,MAAM,SAPL,MAQjB,EAAG,CAACA,EAAO3B,CAAW,CAAC,EAcvB,MAAO,CAAE,mBAZyB6B,EAAAA,YAChC,SAAUK,IACR,MAAMvC,EACJ,GAAGuC,EACHlC,EACAC,EACAC,EACAR,CAAA,EAEJ,CAACM,EAAaC,EAAoBC,CAAiB,CAAA,EAGG,aAAcD,CAAA,CACxE"}
|
|
1
|
+
{"version":3,"file":"viewUpdateHelper.cjs.js","sources":["../../../../../../src/containers/Views/utils/viewUpdateHelper.ts"],"sourcesContent":["/**\n * Shared helper for updating view settings with optimistic local state management.\n *\n * Sequential updateViewSettings calls in the same event tick MUST chain correctly:\n * the second call has to see the first call's changes. Closure-captured\n * `viewSettings` does not refresh between sync calls (no re-render yet), so we\n * read the latest settings from the RTK Query cache at call time instead.\n * RTK's updateView mutation performs an optimistic cache write in\n * `onQueryStarted`, so the cache is already up-to-date by the time the next\n * call reads it.\n */\n\nimport {\n CreateViewApiArg,\n EntityIdResponse,\n useCreateViewMutation,\n useUpdateViewMutation,\n viewsQueries,\n} from '@shared/api'\nimport { generateWorkingView } from './generateWorkingView'\nimport { toast } from 'react-toastify'\nimport { useCallback } from 'react'\nimport { useStore } from 'react-redux'\nimport { useViewsContext, ViewsContextValue, ViewSettings } from '../context/ViewsContext'\n\ninterface UpdateOptions {\n successMessage?: string\n errorMessage?: string\n}\n\n// Module-level flag shared across every useViewUpdateHelper instance. Set true\n// when a mutation has been dispatched in the current tick (RTK cache is now\n// optimistically fresh); reset on the next microtask. Must be module-level so\n// that two different hook instances (e.g. ProjectOverviewDataProvider +\n// ProjectOverviewContext) coordinate correctly when writes flow through one\n// and subsequent reads come from the other in the same event tick.\nlet cacheDirtyThisTick = false\nconst markCacheDirty = () => {\n if (cacheDirtyThisTick) return\n cacheDirtyThisTick = true\n queueMicrotask(() => {\n cacheDirtyThisTick = false\n })\n}\n\nexport type UpdateViewSettingsFn = (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions,\n) => Promise<void>\n\nexport const updateViewSettings = async (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions = {},\n viewContext: ViewsContextValue,\n onApplyViewChanges: (arg: any, viewId?: string) => Promise<EntityIdResponse | void>,\n // Reads latest effective settings from RTK Query cache at call time. Required to\n // prevent stale-closure races when two updates fire in the same tick.\n getLatestSettings: () => ViewSettings | undefined,\n // Invoked synchronously right after the mutation is dispatched. The caller\n // uses this to flip a \"cache is fresh this tick\" flag so subsequent sync\n // calls in the same tick read the just-updated cache instead of stale state.\n markCacheDirty: () => void,\n): Promise<void> => {\n const {\n viewSettings,\n viewType,\n projectName,\n selectedView,\n setSelectedView,\n workingView,\n onSettingsChanged,\n } = viewContext\n\n if (!viewType) throw new Error('No view type provided for updating view settings')\n\n const previousSelectedViewId = selectedView?.id\n const wasWorking = selectedView?.working\n\n try {\n // Immediately update local state for fast UI response\n localStateSetter(newLocalValue)\n\n // Read latest settings from RTK cache (includes prior same-tick optimistic writes).\n // Fallback to closure-captured value if cache has nothing (first render, etc.).\n const latestSettings = getLatestSettings() ?? viewSettings\n\n // Create settings with updates\n const newSettings = { ...latestSettings, ...updatedSettings }\n\n // always update the working view no matter what\n const newWorkingView = generateWorkingView(newSettings)\n\n // Ensure the payload uses the consistent ID if we already have a working view\n const viewId = workingView?.id\n if (viewId) {\n newWorkingView.id = viewId\n }\n const newWorkingViewId = newWorkingView.id\n\n // Make API call in background\n // only include the fields that are updating (just settings)\n const payload = viewId ? { settings: newSettings } : newWorkingView\n\n const promise = onApplyViewChanges(\n {\n payload,\n viewType: viewType,\n projectName: projectName,\n },\n viewId,\n )\n\n // Mutation dispatch above ran onQueryStarted synchronously → RTK cache now\n // reflects `newSettings`. Signal this so any subsequent sync call in the\n // same tick reads the fresh cache instead of the stale closure baseline.\n markCacheDirty()\n\n // if not already on the working view: set that the settings have been changed to show the little blue save button and switch to the working view\n if (!wasWorking) {\n if (selectedView) {\n onSettingsChanged(true)\n }\n setSelectedView(newWorkingViewId as string)\n }\n\n await promise\n\n // Clear local state after successful API call - the server data will take over\n localStateSetter(null)\n\n if (options.successMessage) {\n toast.success(options.successMessage)\n }\n } catch (error) {\n // Revert local state on error\n localStateSetter(null)\n\n if (previousSelectedViewId) {\n setSelectedView(previousSelectedViewId)\n }\n\n if (selectedView && !wasWorking) {\n onSettingsChanged(false)\n }\n\n console.error(error)\n const errorMsg = options.errorMessage || `Failed to update view settings: ${error}`\n toast.error(errorMsg)\n }\n}\n\nexport const useViewUpdateHelper = () => {\n const [createView] = useCreateViewMutation()\n const [updateView] = useUpdateViewMutation()\n\n const viewContext = useViewsContext()\n const store = useStore()\n\n const onApplyViewChanges = useCallback(\n async (arg: any, viewId?: string) => {\n if (viewId) {\n // Filter the payload to only include valid patch fields\n // and ideally only include fields that are actually being updated.\n // Expecting the caller to provide only the fields they want to update in the payload.\n const patchPayload: any = {}\n const patchFields = ['label', 'owner', 'settings']\n patchFields.forEach((key) => {\n if (arg.payload[key] !== undefined) {\n patchPayload[key] = arg.payload[key]\n }\n })\n\n return await updateView({\n viewType: arg.viewType,\n projectName: arg.projectName,\n viewId,\n payload: patchPayload,\n }).unwrap()\n } else {\n return await createView(arg).unwrap()\n }\n },\n [createView, updateView],\n )\n\n // Returns cached settings when a same-tick prior write has refreshed the\n // cache. Otherwise returns undefined and the caller falls back to the\n // closure-captured viewSettings (correct baseline for the first write in a\n // tick, including the named-view → working-view fork).\n const getLatestSettings = useCallback((): ViewSettings | undefined => {\n if (!cacheDirtyThisTick) return undefined\n const { viewType, projectName } = viewContext\n if (!viewType) return undefined\n // RTK selector state is typed against the full RootState; we don't have that\n // type in @shared and the store is project-specific. Cast is safe: the\n // selector only touches the api slice, which exists in every consumer app.\n const entry = viewsQueries.endpoints.getWorkingView.select({ viewType, projectName })(\n store.getState() as any,\n )\n return entry?.data?.settings\n }, [store, viewContext])\n\n const updateViewSettingsHandler = useCallback<UpdateViewSettingsFn>(\n async (...args) =>\n await updateViewSettings(\n ...args,\n viewContext,\n onApplyViewChanges,\n getLatestSettings,\n markCacheDirty,\n ),\n [viewContext, onApplyViewChanges, getLatestSettings],\n )\n\n return {\n updateViewSettings: updateViewSettingsHandler,\n onCreateView: onApplyViewChanges,\n getLatestSettings,\n markCacheDirty,\n }\n}\n"],"names":["cacheDirtyThisTick","markCacheDirty","updateViewSettings","updatedSettings","localStateSetter","newLocalValue","options","viewContext","onApplyViewChanges","getLatestSettings","viewSettings","viewType","projectName","selectedView","setSelectedView","workingView","onSettingsChanged","previousSelectedViewId","wasWorking","newSettings","newWorkingView","generateWorkingView","viewId","newWorkingViewId","promise","toast","error","errorMsg","useViewUpdateHelper","createView","useCreateViewMutation","updateView","useUpdateViewMutation","useViewsContext","store","useStore","useCallback","arg","patchPayload","key","viewsQueries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,wBAAA,EAEfzB,EAAc0B,EAAAA,gBAAA,EACdC,EAAQC,EAAAA,SAAA,EAER3B,EAAqB4B,EAAAA,YACzB,MAAOC,EAAUf,IAAoB,CACnC,GAAIA,EAAQ,CAIV,MAAMgB,EAAoB,CAAA,EAE1B,MADoB,CAAC,QAAS,QAAS,UAAU,EACrC,QAASC,GAAQ,CACvBF,EAAI,QAAQE,CAAG,IAAM,SACvBD,EAAaC,CAAG,EAAIF,EAAI,QAAQE,CAAG,EAEvC,CAAC,EAEM,MAAMR,EAAW,CACtB,SAAUM,EAAI,SACd,YAAaA,EAAI,YACjB,OAAAf,EACA,QAASgB,CAAA,CACV,EAAE,OAAA,CACL,KACE,QAAO,MAAMT,EAAWQ,CAAG,EAAE,OAAA,CAEjC,EACA,CAACR,EAAYE,CAAU,CAAA,EAOnBtB,EAAoB2B,EAAAA,YAAY,IAAgC,CACpE,GAAI,CAACpC,EAAoB,OACzB,KAAM,CAAE,SAAAW,EAAU,YAAAC,CAAA,EAAgBL,EAClC,OAAKI,EAIS6B,EAAAA,aAAa,UAAU,eAAe,OAAO,CAAE,SAAA7B,EAAU,YAAAC,EAAa,EAClFsB,EAAM,SAAA,CAAS,GAEH,MAAM,SAPL,MAQjB,EAAG,CAACA,EAAO3B,CAAW,CAAC,EAcvB,MAAO,CACL,mBAbgC6B,EAAAA,YAChC,SAAUK,IACR,MAAMvC,EACJ,GAAGuC,EACHlC,EACAC,EACAC,EACAR,CAAA,EAEJ,CAACM,EAAaC,EAAoBC,CAAiB,CAAA,EAKnD,aAAcD,EACd,kBAAAC,EACA,eAAAR,CAAA,CAEJ"}
|
|
@@ -87,36 +87,36 @@ import "../../../api/queries/users/updateUsers.es.js";
|
|
|
87
87
|
import "../../../api/queries/users/guests.es.js";
|
|
88
88
|
import "../../../api/queries/versions/updateVersions.es.js";
|
|
89
89
|
import "../../../api/queries/views/getViews.es.js";
|
|
90
|
-
import { useCreateViewMutation as
|
|
90
|
+
import { useCreateViewMutation as W, useUpdateViewMutation as j, viewsQueries as x } from "../../../api/queries/views/updateViews.es.js";
|
|
91
91
|
import "../../../api/queries/watchers/getWatchers.es.js";
|
|
92
92
|
import "../../../api/queries/uris/getUris.es.js";
|
|
93
|
-
import { generateWorkingView as
|
|
93
|
+
import { generateWorkingView as F } from "./generateWorkingView.es.js";
|
|
94
94
|
import { toast as k } from "react-toastify";
|
|
95
95
|
import { useCallback as l } from "react";
|
|
96
|
-
import { useStore as
|
|
97
|
-
import { useViewsContext as
|
|
96
|
+
import { useStore as H } from "react-redux";
|
|
97
|
+
import { useViewsContext as b } from "../context/ViewsContext.es.js";
|
|
98
98
|
let d = !1;
|
|
99
|
-
const
|
|
99
|
+
const C = () => {
|
|
100
100
|
d || (d = !0, queueMicrotask(() => {
|
|
101
101
|
d = !1;
|
|
102
102
|
}));
|
|
103
|
-
}, A = async (
|
|
103
|
+
}, A = async (a, o, r, e = {}, s, n, f, t) => {
|
|
104
104
|
const {
|
|
105
105
|
viewSettings: p,
|
|
106
106
|
viewType: m,
|
|
107
107
|
projectName: V,
|
|
108
108
|
selectedView: i,
|
|
109
109
|
setSelectedView: y,
|
|
110
|
-
workingView:
|
|
110
|
+
workingView: M,
|
|
111
111
|
onSettingsChanged: v
|
|
112
112
|
} = s;
|
|
113
113
|
if (!m) throw new Error("No view type provided for updating view settings");
|
|
114
114
|
const h = i?.id, S = i?.working;
|
|
115
115
|
try {
|
|
116
116
|
o(r);
|
|
117
|
-
const c = { ...f() ?? p, ...
|
|
117
|
+
const c = { ...f() ?? p, ...a }, g = F(c), w = M?.id;
|
|
118
118
|
w && (g.id = w);
|
|
119
|
-
const
|
|
119
|
+
const T = g.id, N = n(
|
|
120
120
|
{
|
|
121
121
|
payload: w ? { settings: c } : g,
|
|
122
122
|
viewType: m,
|
|
@@ -124,14 +124,14 @@ const b = () => {
|
|
|
124
124
|
},
|
|
125
125
|
w
|
|
126
126
|
);
|
|
127
|
-
t(), S || (i && v(!0), y(
|
|
127
|
+
t(), S || (i && v(!0), y(T)), await N, o(null), e.successMessage && k.success(e.successMessage);
|
|
128
128
|
} catch (u) {
|
|
129
129
|
o(null), h && y(h), i && !S && v(!1), console.error(u);
|
|
130
130
|
const c = e.errorMessage || `Failed to update view settings: ${u}`;
|
|
131
131
|
k.error(c);
|
|
132
132
|
}
|
|
133
133
|
}, Mi = () => {
|
|
134
|
-
const [
|
|
134
|
+
const [a] = W(), [o] = j(), r = b(), e = H(), s = l(
|
|
135
135
|
async (t, p) => {
|
|
136
136
|
if (p) {
|
|
137
137
|
const m = {};
|
|
@@ -144,26 +144,31 @@ const b = () => {
|
|
|
144
144
|
payload: m
|
|
145
145
|
}).unwrap();
|
|
146
146
|
} else
|
|
147
|
-
return await
|
|
147
|
+
return await a(t).unwrap();
|
|
148
148
|
},
|
|
149
|
-
[
|
|
150
|
-
),
|
|
149
|
+
[a, o]
|
|
150
|
+
), n = l(() => {
|
|
151
151
|
if (!d) return;
|
|
152
152
|
const { viewType: t, projectName: p } = r;
|
|
153
|
-
return t ?
|
|
153
|
+
return t ? x.endpoints.getWorkingView.select({ viewType: t, projectName: p })(
|
|
154
154
|
e.getState()
|
|
155
155
|
)?.data?.settings : void 0;
|
|
156
156
|
}, [e, r]);
|
|
157
|
-
return {
|
|
158
|
-
|
|
159
|
-
...t
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
157
|
+
return {
|
|
158
|
+
updateViewSettings: l(
|
|
159
|
+
async (...t) => await A(
|
|
160
|
+
...t,
|
|
161
|
+
r,
|
|
162
|
+
s,
|
|
163
|
+
n,
|
|
164
|
+
C
|
|
165
|
+
),
|
|
166
|
+
[r, s, n]
|
|
164
167
|
),
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
onCreateView: s,
|
|
169
|
+
getLatestSettings: n,
|
|
170
|
+
markCacheDirty: C
|
|
171
|
+
};
|
|
167
172
|
};
|
|
168
173
|
export {
|
|
169
174
|
A as updateViewSettings,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewUpdateHelper.es.js","sources":["../../../../../../src/containers/Views/utils/viewUpdateHelper.ts"],"sourcesContent":["/**\n * Shared helper for updating view settings with optimistic local state management.\n *\n * Sequential updateViewSettings calls in the same event tick MUST chain correctly:\n * the second call has to see the first call's changes. Closure-captured\n * `viewSettings` does not refresh between sync calls (no re-render yet), so we\n * read the latest settings from the RTK Query cache at call time instead.\n * RTK's updateView mutation performs an optimistic cache write in\n * `onQueryStarted`, so the cache is already up-to-date by the time the next\n * call reads it.\n */\n\nimport {\n CreateViewApiArg,\n EntityIdResponse,\n useCreateViewMutation,\n useUpdateViewMutation,\n viewsQueries,\n} from '@shared/api'\nimport { generateWorkingView } from './generateWorkingView'\nimport { toast } from 'react-toastify'\nimport { useCallback } from 'react'\nimport { useStore } from 'react-redux'\nimport { useViewsContext, ViewsContextValue, ViewSettings } from '../context/ViewsContext'\n\ninterface UpdateOptions {\n successMessage?: string\n errorMessage?: string\n}\n\n// Module-level flag shared across every useViewUpdateHelper instance. Set true\n// when a mutation has been dispatched in the current tick (RTK cache is now\n// optimistically fresh); reset on the next microtask. Must be module-level so\n// that two different hook instances (e.g. ProjectOverviewDataProvider +\n// ProjectOverviewContext) coordinate correctly when writes flow through one\n// and subsequent reads come from the other in the same event tick.\nlet cacheDirtyThisTick = false\nconst markCacheDirty = () => {\n if (cacheDirtyThisTick) return\n cacheDirtyThisTick = true\n queueMicrotask(() => {\n cacheDirtyThisTick = false\n })\n}\n\nexport type UpdateViewSettingsFn = (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions,\n) => Promise<void>\n\nexport const updateViewSettings = async (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions = {},\n viewContext: ViewsContextValue,\n onApplyViewChanges: (arg: any, viewId?: string) => Promise<EntityIdResponse | void>,\n // Reads latest effective settings from RTK Query cache at call time. Required to\n // prevent stale-closure races when two updates fire in the same tick.\n getLatestSettings: () => ViewSettings | undefined,\n // Invoked synchronously right after the mutation is dispatched. The caller\n // uses this to flip a \"cache is fresh this tick\" flag so subsequent sync\n // calls in the same tick read the just-updated cache instead of stale state.\n markCacheDirty: () => void,\n): Promise<void> => {\n const {\n viewSettings,\n viewType,\n projectName,\n selectedView,\n setSelectedView,\n workingView,\n onSettingsChanged,\n } = viewContext\n\n if (!viewType) throw new Error('No view type provided for updating view settings')\n\n const previousSelectedViewId = selectedView?.id\n const wasWorking = selectedView?.working\n\n try {\n // Immediately update local state for fast UI response\n localStateSetter(newLocalValue)\n\n // Read latest settings from RTK cache (includes prior same-tick optimistic writes).\n // Fallback to closure-captured value if cache has nothing (first render, etc.).\n const latestSettings = getLatestSettings() ?? viewSettings\n\n // Create settings with updates\n const newSettings = { ...latestSettings, ...updatedSettings }\n\n // always update the working view no matter what\n const newWorkingView = generateWorkingView(newSettings)\n\n // Ensure the payload uses the consistent ID if we already have a working view\n const viewId = workingView?.id\n if (viewId) {\n newWorkingView.id = viewId\n }\n const newWorkingViewId = newWorkingView.id\n\n // Make API call in background\n // only include the fields that are updating (just settings)\n const payload = viewId ? { settings: newSettings } : newWorkingView\n\n const promise = onApplyViewChanges(\n {\n payload,\n viewType: viewType,\n projectName: projectName,\n },\n viewId,\n )\n\n // Mutation dispatch above ran onQueryStarted synchronously → RTK cache now\n // reflects `newSettings`. Signal this so any subsequent sync call in the\n // same tick reads the fresh cache instead of the stale closure baseline.\n markCacheDirty()\n\n // if not already on the working view: set that the settings have been changed to show the little blue save button and switch to the working view\n if (!wasWorking) {\n if (selectedView) {\n onSettingsChanged(true)\n }\n setSelectedView(newWorkingViewId as string)\n }\n\n await promise\n\n // Clear local state after successful API call - the server data will take over\n localStateSetter(null)\n\n if (options.successMessage) {\n toast.success(options.successMessage)\n }\n } catch (error) {\n // Revert local state on error\n localStateSetter(null)\n\n if (previousSelectedViewId) {\n setSelectedView(previousSelectedViewId)\n }\n\n if (selectedView && !wasWorking) {\n onSettingsChanged(false)\n }\n\n console.error(error)\n const errorMsg = options.errorMessage || `Failed to update view settings: ${error}`\n toast.error(errorMsg)\n }\n}\n\nexport const useViewUpdateHelper = () => {\n const [createView] = useCreateViewMutation()\n const [updateView] = useUpdateViewMutation()\n\n const viewContext = useViewsContext()\n const store = useStore()\n\n const onApplyViewChanges = useCallback(\n async (arg: any, viewId?: string) => {\n if (viewId) {\n // Filter the payload to only include valid patch fields\n // and ideally only include fields that are actually being updated.\n // Expecting the caller to provide only the fields they want to update in the payload.\n const patchPayload: any = {}\n const patchFields = ['label', 'owner', 'settings']\n patchFields.forEach((key) => {\n if (arg.payload[key] !== undefined) {\n patchPayload[key] = arg.payload[key]\n }\n })\n\n return await updateView({\n viewType: arg.viewType,\n projectName: arg.projectName,\n viewId,\n payload: patchPayload,\n }).unwrap()\n } else {\n return await createView(arg).unwrap()\n }\n },\n [createView, updateView],\n )\n\n // Returns cached settings when a same-tick prior write has refreshed the\n // cache. Otherwise returns undefined and the caller falls back to the\n // closure-captured viewSettings (correct baseline for the first write in a\n // tick, including the named-view → working-view fork).\n const getLatestSettings = useCallback((): ViewSettings | undefined => {\n if (!cacheDirtyThisTick) return undefined\n const { viewType, projectName } = viewContext\n if (!viewType) return undefined\n // RTK selector state is typed against the full RootState; we don't have that\n // type in @shared and the store is project-specific. Cast is safe: the\n // selector only touches the api slice, which exists in every consumer app.\n const entry = viewsQueries.endpoints.getWorkingView.select({ viewType, projectName })(\n store.getState() as any,\n )\n return entry?.data?.settings\n }, [store, viewContext])\n\n const updateViewSettingsHandler = useCallback<UpdateViewSettingsFn>(\n async (...args) =>\n await updateViewSettings(\n ...args,\n viewContext,\n onApplyViewChanges,\n getLatestSettings,\n markCacheDirty,\n ),\n [viewContext, onApplyViewChanges, getLatestSettings],\n )\n\n return { updateViewSettings: updateViewSettingsHandler, onCreateView: onApplyViewChanges }\n}\n"],"names":["cacheDirtyThisTick","markCacheDirty","updateViewSettings","updatedSettings","localStateSetter","newLocalValue","options","viewContext","onApplyViewChanges","getLatestSettings","viewSettings","viewType","projectName","selectedView","setSelectedView","workingView","onSettingsChanged","previousSelectedViewId","wasWorking","newSettings","newWorkingView","generateWorkingView","viewId","newWorkingViewId","promise","toast","error","errorMsg","useViewUpdateHelper","createView","useCreateViewMutation","updateView","useUpdateViewMutation","useViewsContext","store","useStore","useCallback","arg","patchPayload","key","viewsQueries","args"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAIA,IAAqB;AACzB,MAAMC,IAAiB,MAAM;AAC3B,EAAID,MACJA,IAAqB,IACrB,eAAe,MAAM;AACnB,IAAAA,IAAqB;AAAA,EACvB,CAAC;AACH,GASaE,IAAqB,OAChCC,GACAC,GACAC,GACAC,IAAyB,CAAA,GACzBC,GACAC,GAGAC,GAIAR,MACkB;AAClB,QAAM;AAAA,IACJ,cAAAS;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,cAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,mBAAAC;AAAA,EAAA,IACET;AAEJ,MAAI,CAACI,EAAU,OAAM,IAAI,MAAM,kDAAkD;AAEjF,QAAMM,IAAyBJ,GAAc,IACvCK,IAAaL,GAAc;AAEjC,MAAI;AAEF,IAAAT,EAAiBC,CAAa;AAO9B,UAAMc,IAAc,EAAE,GAHCV,OAAuBC,GAGL,GAAGP,EAAA,GAGtCiB,IAAiBC,EAAoBF,CAAW,GAGhDG,IAASP,GAAa;AAC5B,IAAIO,MACFF,EAAe,KAAKE;AAEtB,UAAMC,IAAmBH,EAAe,IAMlCI,IAAUhB;AAAA,MACd;AAAA,QACE,SAJYc,IAAS,EAAE,UAAUH,MAAgBC;AAAA,QAKjD,UAAAT;AAAA,QACA,aAAAC;AAAA,MAAA;AAAA,MAEFU;AAAA,IAAA;AAMFrB,IAAAA,EAAAA,GAGK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AAAA,MAClFsB,EAAM,SAAA;AAAA,IAAS,GAEH,MAAM,WAPL;AAAA,EAQjB,GAAG,CAACA,GAAO3B,CAAW,CAAC;AAcvB,SAAO,EAAE,oBAZyB6B;AAAA,IAChC,UAAUK,MACR,MAAMvC;AAAA,MACJ,GAAGuC;AAAA,MACHlC;AAAA,MACAC;AAAA,MACAC;AAAA,MACAR;AAAA,IAAA;AAAA,IAEJ,CAACM,GAAaC,GAAoBC,CAAiB;AAAA,EAAA,GAGG,cAAcD,EAAA;AACxE;"}
|
|
1
|
+
{"version":3,"file":"viewUpdateHelper.es.js","sources":["../../../../../../src/containers/Views/utils/viewUpdateHelper.ts"],"sourcesContent":["/**\n * Shared helper for updating view settings with optimistic local state management.\n *\n * Sequential updateViewSettings calls in the same event tick MUST chain correctly:\n * the second call has to see the first call's changes. Closure-captured\n * `viewSettings` does not refresh between sync calls (no re-render yet), so we\n * read the latest settings from the RTK Query cache at call time instead.\n * RTK's updateView mutation performs an optimistic cache write in\n * `onQueryStarted`, so the cache is already up-to-date by the time the next\n * call reads it.\n */\n\nimport {\n CreateViewApiArg,\n EntityIdResponse,\n useCreateViewMutation,\n useUpdateViewMutation,\n viewsQueries,\n} from '@shared/api'\nimport { generateWorkingView } from './generateWorkingView'\nimport { toast } from 'react-toastify'\nimport { useCallback } from 'react'\nimport { useStore } from 'react-redux'\nimport { useViewsContext, ViewsContextValue, ViewSettings } from '../context/ViewsContext'\n\ninterface UpdateOptions {\n successMessage?: string\n errorMessage?: string\n}\n\n// Module-level flag shared across every useViewUpdateHelper instance. Set true\n// when a mutation has been dispatched in the current tick (RTK cache is now\n// optimistically fresh); reset on the next microtask. Must be module-level so\n// that two different hook instances (e.g. ProjectOverviewDataProvider +\n// ProjectOverviewContext) coordinate correctly when writes flow through one\n// and subsequent reads come from the other in the same event tick.\nlet cacheDirtyThisTick = false\nconst markCacheDirty = () => {\n if (cacheDirtyThisTick) return\n cacheDirtyThisTick = true\n queueMicrotask(() => {\n cacheDirtyThisTick = false\n })\n}\n\nexport type UpdateViewSettingsFn = (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions,\n) => Promise<void>\n\nexport const updateViewSettings = async (\n updatedSettings: any,\n localStateSetter: (value: any) => void,\n newLocalValue: any,\n options: UpdateOptions = {},\n viewContext: ViewsContextValue,\n onApplyViewChanges: (arg: any, viewId?: string) => Promise<EntityIdResponse | void>,\n // Reads latest effective settings from RTK Query cache at call time. Required to\n // prevent stale-closure races when two updates fire in the same tick.\n getLatestSettings: () => ViewSettings | undefined,\n // Invoked synchronously right after the mutation is dispatched. The caller\n // uses this to flip a \"cache is fresh this tick\" flag so subsequent sync\n // calls in the same tick read the just-updated cache instead of stale state.\n markCacheDirty: () => void,\n): Promise<void> => {\n const {\n viewSettings,\n viewType,\n projectName,\n selectedView,\n setSelectedView,\n workingView,\n onSettingsChanged,\n } = viewContext\n\n if (!viewType) throw new Error('No view type provided for updating view settings')\n\n const previousSelectedViewId = selectedView?.id\n const wasWorking = selectedView?.working\n\n try {\n // Immediately update local state for fast UI response\n localStateSetter(newLocalValue)\n\n // Read latest settings from RTK cache (includes prior same-tick optimistic writes).\n // Fallback to closure-captured value if cache has nothing (first render, etc.).\n const latestSettings = getLatestSettings() ?? viewSettings\n\n // Create settings with updates\n const newSettings = { ...latestSettings, ...updatedSettings }\n\n // always update the working view no matter what\n const newWorkingView = generateWorkingView(newSettings)\n\n // Ensure the payload uses the consistent ID if we already have a working view\n const viewId = workingView?.id\n if (viewId) {\n newWorkingView.id = viewId\n }\n const newWorkingViewId = newWorkingView.id\n\n // Make API call in background\n // only include the fields that are updating (just settings)\n const payload = viewId ? { settings: newSettings } : newWorkingView\n\n const promise = onApplyViewChanges(\n {\n payload,\n viewType: viewType,\n projectName: projectName,\n },\n viewId,\n )\n\n // Mutation dispatch above ran onQueryStarted synchronously → RTK cache now\n // reflects `newSettings`. Signal this so any subsequent sync call in the\n // same tick reads the fresh cache instead of the stale closure baseline.\n markCacheDirty()\n\n // if not already on the working view: set that the settings have been changed to show the little blue save button and switch to the working view\n if (!wasWorking) {\n if (selectedView) {\n onSettingsChanged(true)\n }\n setSelectedView(newWorkingViewId as string)\n }\n\n await promise\n\n // Clear local state after successful API call - the server data will take over\n localStateSetter(null)\n\n if (options.successMessage) {\n toast.success(options.successMessage)\n }\n } catch (error) {\n // Revert local state on error\n localStateSetter(null)\n\n if (previousSelectedViewId) {\n setSelectedView(previousSelectedViewId)\n }\n\n if (selectedView && !wasWorking) {\n onSettingsChanged(false)\n }\n\n console.error(error)\n const errorMsg = options.errorMessage || `Failed to update view settings: ${error}`\n toast.error(errorMsg)\n }\n}\n\nexport const useViewUpdateHelper = () => {\n const [createView] = useCreateViewMutation()\n const [updateView] = useUpdateViewMutation()\n\n const viewContext = useViewsContext()\n const store = useStore()\n\n const onApplyViewChanges = useCallback(\n async (arg: any, viewId?: string) => {\n if (viewId) {\n // Filter the payload to only include valid patch fields\n // and ideally only include fields that are actually being updated.\n // Expecting the caller to provide only the fields they want to update in the payload.\n const patchPayload: any = {}\n const patchFields = ['label', 'owner', 'settings']\n patchFields.forEach((key) => {\n if (arg.payload[key] !== undefined) {\n patchPayload[key] = arg.payload[key]\n }\n })\n\n return await updateView({\n viewType: arg.viewType,\n projectName: arg.projectName,\n viewId,\n payload: patchPayload,\n }).unwrap()\n } else {\n return await createView(arg).unwrap()\n }\n },\n [createView, updateView],\n )\n\n // Returns cached settings when a same-tick prior write has refreshed the\n // cache. Otherwise returns undefined and the caller falls back to the\n // closure-captured viewSettings (correct baseline for the first write in a\n // tick, including the named-view → working-view fork).\n const getLatestSettings = useCallback((): ViewSettings | undefined => {\n if (!cacheDirtyThisTick) return undefined\n const { viewType, projectName } = viewContext\n if (!viewType) return undefined\n // RTK selector state is typed against the full RootState; we don't have that\n // type in @shared and the store is project-specific. Cast is safe: the\n // selector only touches the api slice, which exists in every consumer app.\n const entry = viewsQueries.endpoints.getWorkingView.select({ viewType, projectName })(\n store.getState() as any,\n )\n return entry?.data?.settings\n }, [store, viewContext])\n\n const updateViewSettingsHandler = useCallback<UpdateViewSettingsFn>(\n async (...args) =>\n await updateViewSettings(\n ...args,\n viewContext,\n onApplyViewChanges,\n getLatestSettings,\n markCacheDirty,\n ),\n [viewContext, onApplyViewChanges, getLatestSettings],\n )\n\n return {\n updateViewSettings: updateViewSettingsHandler,\n onCreateView: onApplyViewChanges,\n getLatestSettings,\n markCacheDirty,\n }\n}\n"],"names":["cacheDirtyThisTick","markCacheDirty","updateViewSettings","updatedSettings","localStateSetter","newLocalValue","options","viewContext","onApplyViewChanges","getLatestSettings","viewSettings","viewType","projectName","selectedView","setSelectedView","workingView","onSettingsChanged","previousSelectedViewId","wasWorking","newSettings","newWorkingView","generateWorkingView","viewId","newWorkingViewId","promise","toast","error","errorMsg","useViewUpdateHelper","createView","useCreateViewMutation","updateView","useUpdateViewMutation","useViewsContext","store","useStore","useCallback","arg","patchPayload","key","viewsQueries","args"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAIA,IAAqB;AACzB,MAAMC,IAAiB,MAAM;AAC3B,EAAID,MACJA,IAAqB,IACrB,eAAe,MAAM;AACnB,IAAAA,IAAqB;AAAA,EACvB,CAAC;AACH,GASaE,IAAqB,OAChCC,GACAC,GACAC,GACAC,IAAyB,CAAA,GACzBC,GACAC,GAGAC,GAIAR,MACkB;AAClB,QAAM;AAAA,IACJ,cAAAS;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,cAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,mBAAAC;AAAA,EAAA,IACET;AAEJ,MAAI,CAACI,EAAU,OAAM,IAAI,MAAM,kDAAkD;AAEjF,QAAMM,IAAyBJ,GAAc,IACvCK,IAAaL,GAAc;AAEjC,MAAI;AAEF,IAAAT,E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AAA,UACjB,QAAAf;AAAA,UACA,SAASgB;AAAA,QAAA,CACV,EAAE,OAAA;AAAA,MACL;AACE,eAAO,MAAMT,EAAWQ,CAAG,EAAE,OAAA;AAAA,IAEjC;AAAA,IACA,CAACR,GAAYE,CAAU;AAAA,EAAA,GAOnBtB,IAAoB2B,EAAY,MAAgC;AACpE,QAAI,CAACpC,EAAoB;AACzB,UAAM,EAAE,UAAAW,GAAU,aAAAC,EAAA,IAAgBL;AAClC,WAAKI,IAIS6B,EAAa,UAAU,eAAe,OAAO,EAAE,UAAA7B,GAAU,aAAAC,GAAa;AAAA,MAClFsB,EAAM,SAAA;AAAA,IAAS,GAEH,MAAM,WAPL;AAAA,EAQjB,GAAG,CAACA,GAAO3B,CAAW,CAAC;AAcvB,SAAO;AAAA,IACL,oBAbgC6B;AAAA,MAChC,UAAUK,MACR,MAAMvC;AAAA,QACJ,GAAGuC;AAAA,QACHlC;AAAA,QACAC;AAAA,QACAC;AAAA,QACAR;AAAA,MAAA;AAAA,MAEJ,CAACM,GAAaC,GAAoBC,CAAiB;AAAA,IAAA;AAAA,IAKnD,cAAcD;AAAA,IACd,mBAAAC;AAAA,IACA,gBAAAR;AAAA,EAAA;AAEJ;"}
|
|
@@ -9,5 +9,7 @@ export declare const updateViewSettings: (updatedSettings: any, localStateSetter
|
|
|
9
9
|
export declare const useViewUpdateHelper: () => {
|
|
10
10
|
updateViewSettings: UpdateViewSettingsFn;
|
|
11
11
|
onCreateView: (arg: any, viewId?: string) => Promise<any>;
|
|
12
|
+
getLatestSettings: () => ViewSettings | undefined;
|
|
13
|
+
markCacheDirty: () => void;
|
|
12
14
|
};
|
|
13
15
|
export {};
|