diff --git a/editor/src/components/editor/actions/actions.tsx b/editor/src/components/editor/actions/actions.tsx index 491508909bc6..6959c6825dd7 100644 --- a/editor/src/components/editor/actions/actions.tsx +++ b/editor/src/components/editor/actions/actions.tsx @@ -315,7 +315,7 @@ import type { } from '../action-types' import { isLoggedIn } from '../action-types' import type { Mode } from '../editor-modes' -import { isFollowMode, isTextEditMode } from '../editor-modes' +import { isCommentMode, isFollowMode, isTextEditMode } from '../editor-modes' import { EditorModes, isLiveMode, isSelectMode } from '../editor-modes' import * as History from '../history' import type { StateHistory } from '../history' @@ -2054,7 +2054,7 @@ export const UPDATE_FNS = { SWITCH_EDITOR_MODE: ( action: SwitchEditorMode, editor: EditorModel, - derived: DerivedState, + userState: UserState, ): EditorModel => { // TODO this should probably be merged with UPDATE_EDITOR_MODE if (action.unlessMode === editor.mode.type) { @@ -2076,6 +2076,9 @@ export const UPDATE_FNS = { return editor } } + if (isCommentMode(action.mode) && !isLoggedIn(userState.loginState)) { + return editor + } return setModeState(action.mode, editor) }, TOGGLE_CANVAS_IS_LIVE: (editor: EditorModel, derived: DerivedState): EditorModel => { @@ -3078,7 +3081,6 @@ export const UPDATE_FNS = { SAVE_ASSET: ( action: SaveAsset, editor: EditorModel, - derived: DerivedState, dispatch: EditorDispatch, userState: UserState, ): EditorModel => { @@ -3220,7 +3222,7 @@ export const UPDATE_FNS = { const editorInsertEnabled = UPDATE_FNS.SWITCH_EDITOR_MODE( switchMode, editorWithToast, - derived, + userState, ) return { ...editorInsertEnabled, @@ -3302,7 +3304,7 @@ export const UPDATE_FNS = { INSERT_IMAGE_INTO_UI: ( action: InsertImageIntoUI, editor: EditorModel, - derived: DerivedState, + userState: UserState, ): EditorModel => { const possiblyAnImage = getProjectFileByFilePath(editor.projectContents, action.imagePath) if (possiblyAnImage != null && isImageFile(possiblyAnImage)) { @@ -3332,7 +3334,7 @@ export const UPDATE_FNS = { ) const size = width != null && height != null ? { width: width, height: height } : null const switchMode = enableInsertModeForJSXElement(imageElement, newUID, {}, size) - return UPDATE_FNS.SWITCH_EDITOR_MODE(switchMode, editor, derived) + return UPDATE_FNS.SWITCH_EDITOR_MODE(switchMode, editor, userState) } else { return editor } diff --git a/editor/src/components/editor/store/editor-update.tsx b/editor/src/components/editor/store/editor-update.tsx index 326b66151ba8..e88616e99543 100644 --- a/editor/src/components/editor/store/editor-update.tsx +++ b/editor/src/components/editor/store/editor-update.tsx @@ -42,7 +42,7 @@ export function runLocalEditorAction( case 'DISTRIBUTE_SELECTED_VIEWS': return UPDATE_FNS.DISTRIBUTE_SELECTED_VIEWS(action, state) case 'SAVE_ASSET': - return UPDATE_FNS.SAVE_ASSET(action, state, derivedState, dispatch, userState) + return UPDATE_FNS.SAVE_ASSET(action, state, dispatch, userState) default: return runSimpleLocalEditorAction( state, @@ -105,7 +105,7 @@ export function runSimpleLocalEditorAction( case 'UPDATE_EDITOR_MODE': return UPDATE_FNS.UPDATE_EDITOR_MODE(action, state) case 'SWITCH_EDITOR_MODE': - return UPDATE_FNS.SWITCH_EDITOR_MODE(action, state, derivedState) + return UPDATE_FNS.SWITCH_EDITOR_MODE(action, state, userState) case 'TOGGLE_HIDDEN': return UPDATE_FNS.TOGGLE_HIDDEN(action, state) case 'RENAME_COMPONENT': @@ -274,7 +274,7 @@ export function runSimpleLocalEditorAction( case 'UNWRAP_ELEMENTS': return UPDATE_FNS.UNWRAP_ELEMENTS(action, state, dispatch, builtInDependencies) case 'INSERT_IMAGE_INTO_UI': - return UPDATE_FNS.INSERT_IMAGE_INTO_UI(action, state, derivedState) + return UPDATE_FNS.INSERT_IMAGE_INTO_UI(action, state, userState) case 'UPDATE_JSX_ELEMENT_NAME': return UPDATE_FNS.UPDATE_JSX_ELEMENT_NAME(action, state) case 'ADD_IMPORTS':