Skip to content

Commit

Permalink
fix(editor) Renamed the UPDATE_TOP_LEVEL_ELEMENTS action.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanparsons committed Nov 17, 2023
1 parent 8dd0039 commit ea4a8cf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions editor/src/components/editor/action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TopLevelElement>
}
Expand Down Expand Up @@ -1227,7 +1227,7 @@ export type EditorAction =
| FromVSCodeAction
| TruncateHistory
| UpdateProjectServerState
| UpdateTopLevelElements
| UpdateTopLevelElementsFromCollaborationUpdate

export type DispatchPriority =
| 'everyone'
Expand Down
8 changes: 4 additions & 4 deletions editor/src/components/editor/actions/action-creators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -1664,12 +1664,12 @@ export function updateProjectServerState(
}
}

export function updateTopLevelElements(
export function updateTopLevelElementsFromCollaborationUpdate(
fullPath: string,
topLevelElements: Array<TopLevelElement>,
): UpdateTopLevelElements {
): UpdateTopLevelElementsFromCollaborationUpdate {
return {
action: 'UPDATE_TOP_LEVEL_ELEMENTS',
action: 'UPDATE_TOP_LEVEL_ELEMENTS_FROM_COLLABORATION_UPDATE',
fullPath: fullPath,
topLevelElements: topLevelElements,
}
Expand Down
2 changes: 1 addition & 1 deletion editor/src/components/editor/actions/action-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
7 changes: 5 additions & 2 deletions editor/src/components/editor/actions/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions editor/src/components/editor/store/collaborative-editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -254,7 +254,7 @@ function updateEntireProjectContents(
case 'add':
if (changeEntry.newValue != null) {
actions.push(
updateTopLevelElements(
updateTopLevelElementsFromCollaborationUpdate(
filename,
(changeEntry.newValue as CollabTextFileTopLevelElements).toArray(),
),
Expand Down Expand Up @@ -302,7 +302,7 @@ function updateTopLevelElementsOfFile(
newTopLevelElements.push(...elementsToPush)
}

dispatch([updateTopLevelElements(filePath, newTopLevelElements)])
dispatch([updateTopLevelElementsFromCollaborationUpdate(filePath, newTopLevelElements)])
}
}

Expand Down
4 changes: 2 additions & 2 deletions editor/src/components/editor/store/editor-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit ea4a8cf

Please sign in to comment.