From ea4a8cf0e93f9f00840b7501da110693549393e6 Mon Sep 17 00:00:00 2001 From: Sean Parsons Date: Fri, 17 Nov 2023 17:59:09 +0000 Subject: [PATCH] fix(editor) Renamed the UPDATE_TOP_LEVEL_ELEMENTS action. --- editor/src/components/editor/action-types.ts | 6 +++--- editor/src/components/editor/actions/action-creators.ts | 8 ++++---- editor/src/components/editor/actions/action-utils.ts | 2 +- editor/src/components/editor/actions/actions.tsx | 7 +++++-- .../src/components/editor/store/collaborative-editing.ts | 6 +++--- editor/src/components/editor/store/editor-update.tsx | 4 ++-- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/editor/src/components/editor/action-types.ts b/editor/src/components/editor/action-types.ts index 4cd0e9a5e47b..4325d9eb9cc8 100644 --- a/editor/src/components/editor/action-types.ts +++ b/editor/src/components/editor/action-types.ts @@ -1051,8 +1051,8 @@ export interface UpdateProjectServerState { serverState: ProjectServerState } -export interface UpdateTopLevelElements { - action: 'UPDATE_TOP_LEVEL_ELEMENTS' +export interface UpdateTopLevelElementsFromCollaborationUpdate { + action: 'UPDATE_TOP_LEVEL_ELEMENTS_FROM_COLLABORATION_UPDATE' fullPath: string topLevelElements: Array } @@ -1227,7 +1227,7 @@ export type EditorAction = | FromVSCodeAction | TruncateHistory | UpdateProjectServerState - | UpdateTopLevelElements + | UpdateTopLevelElementsFromCollaborationUpdate export type DispatchPriority = | 'everyone' diff --git a/editor/src/components/editor/actions/action-creators.ts b/editor/src/components/editor/actions/action-creators.ts index 4c4d19bc9737..d3bde825d111 100644 --- a/editor/src/components/editor/actions/action-creators.ts +++ b/editor/src/components/editor/actions/action-creators.ts @@ -220,7 +220,7 @@ import type { WrapInElementWith, ScrollToPosition, UpdateProjectServerState, - UpdateTopLevelElements, + UpdateTopLevelElementsFromCollaborationUpdate, } from '../action-types' import type { InsertionSubjectWrapper, Mode } from '../editor-modes' import { EditorModes, insertionSubject } from '../editor-modes' @@ -1664,12 +1664,12 @@ export function updateProjectServerState( } } -export function updateTopLevelElements( +export function updateTopLevelElementsFromCollaborationUpdate( fullPath: string, topLevelElements: Array, -): UpdateTopLevelElements { +): UpdateTopLevelElementsFromCollaborationUpdate { return { - action: 'UPDATE_TOP_LEVEL_ELEMENTS', + action: 'UPDATE_TOP_LEVEL_ELEMENTS_FROM_COLLABORATION_UPDATE', fullPath: fullPath, topLevelElements: topLevelElements, } diff --git a/editor/src/components/editor/actions/action-utils.ts b/editor/src/components/editor/actions/action-utils.ts index 7d2f7fa2decb..f8737c9cdcb0 100644 --- a/editor/src/components/editor/actions/action-utils.ts +++ b/editor/src/components/editor/actions/action-utils.ts @@ -196,7 +196,7 @@ export function isTransientAction(action: EditorAction): boolean { case 'SWITCH_CONDITIONAL_BRANCHES': case 'UPDATE_CONIDTIONAL_EXPRESSION': case 'CUT_SELECTION_TO_CLIPBOARD': - case 'UPDATE_TOP_LEVEL_ELEMENTS': + case 'UPDATE_TOP_LEVEL_ELEMENTS_FROM_COLLABORATION_UPDATE': return false case 'SAVE_ASSET': return ( diff --git a/editor/src/components/editor/actions/actions.tsx b/editor/src/components/editor/actions/actions.tsx index 3880755f4fe0..dd6993e232cc 100644 --- a/editor/src/components/editor/actions/actions.tsx +++ b/editor/src/components/editor/actions/actions.tsx @@ -311,7 +311,7 @@ import type { UpdateConditionalExpression, SetMapCountOverride, ScrollToPosition, - UpdateTopLevelElements, + UpdateTopLevelElementsFromCollaborationUpdate, } from '../action-types' import { isLoggedIn } from '../action-types' import type { Mode } from '../editor-modes' @@ -5332,7 +5332,10 @@ export const UPDATE_FNS = { return updatedEditor }, - UPDATE_TOP_LEVEL_ELEMENTS: (action: UpdateTopLevelElements, editor: EditorModel): EditorModel => { + UPDATE_TOP_LEVEL_ELEMENTS_FROM_COLLABORATION_UPDATE: ( + action: UpdateTopLevelElementsFromCollaborationUpdate, + editor: EditorModel, + ): EditorModel => { const updatedEditor = modifyParseSuccessAtPath( action.fullPath, editor, diff --git a/editor/src/components/editor/store/collaborative-editing.ts b/editor/src/components/editor/store/collaborative-editing.ts index a1b6a1a34607..69d90bcf3dac 100644 --- a/editor/src/components/editor/store/collaborative-editing.ts +++ b/editor/src/components/editor/store/collaborative-editing.ts @@ -24,7 +24,7 @@ import type { EditorAction, EditorDispatch } from '../action-types' import { deleteFile, updateProjectContents, - updateTopLevelElements, + updateTopLevelElementsFromCollaborationUpdate, } from '../actions/action-creators' import { assertNever, isBrowserEnvironment } from '../../../core/shared/utils' import type { ParseSuccess } from '../../../core/shared/project-file-types' @@ -254,7 +254,7 @@ function updateEntireProjectContents( case 'add': if (changeEntry.newValue != null) { actions.push( - updateTopLevelElements( + updateTopLevelElementsFromCollaborationUpdate( filename, (changeEntry.newValue as CollabTextFileTopLevelElements).toArray(), ), @@ -302,7 +302,7 @@ function updateTopLevelElementsOfFile( newTopLevelElements.push(...elementsToPush) } - dispatch([updateTopLevelElements(filePath, newTopLevelElements)]) + dispatch([updateTopLevelElementsFromCollaborationUpdate(filePath, newTopLevelElements)]) } } diff --git a/editor/src/components/editor/store/editor-update.tsx b/editor/src/components/editor/store/editor-update.tsx index 15c3d8671986..b3acab471aac 100644 --- a/editor/src/components/editor/store/editor-update.tsx +++ b/editor/src/components/editor/store/editor-update.tsx @@ -388,8 +388,8 @@ export function runSimpleLocalEditorAction( return UPDATE_FNS.UPDATE_CONDITIONAL_EXPRESSION(action, state) case 'SWITCH_CONDITIONAL_BRANCHES': return UPDATE_FNS.SWITCH_CONDITIONAL_BRANCHES(action, state) - case 'UPDATE_TOP_LEVEL_ELEMENTS': - return UPDATE_FNS.UPDATE_TOP_LEVEL_ELEMENTS(action, state) + case 'UPDATE_TOP_LEVEL_ELEMENTS_FROM_COLLABORATION_UPDATE': + return UPDATE_FNS.UPDATE_TOP_LEVEL_ELEMENTS_FROM_COLLABORATION_UPDATE(action, state) default: return state }