Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene dragging: do not save new scene comment canvas position in every frame #4872

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions editor/src/core/commenting/comment-maintainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getIdOfScene } from '../../components/canvas/controls/comment-mode/comm
import * as EP from '../shared/element-path'
import { isNotNullFiniteRectangle } from '../shared/math-utils'
import { isCanvasThreadMetadata, liveblocksThreadMetadataToUtopia } from './comment-types'
import { Substores, useEditorState } from '../../components/editor/store/store-hook'

export const CommentMaintainer = React.memo(() => {
const canComment = useCanComment()
Expand Down Expand Up @@ -34,6 +35,16 @@ function useMaintainComments() {
const scenes = useScenes()
const editThreadMetadata = useEditThreadMetadata()

const isInteraction = useEditorState(
Substores.canvas,
(store) => store.editor.canvas.interactionSession != null,
'useMaintainComments isInteraction',
)

if (isInteraction) {
return
}

threads.forEach(async (t): Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhmmmmmm, are we directly calling editThreadMetadata from render? shouldn't this part be wrapped in a useEffect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This triggers an async liveblocks update but does not wait for it, so it did not seem dangerous to me.

const metadata = liveblocksThreadMetadataToUtopia(t.metadata)
if (isCanvasThreadMetadata(metadata)) {
Expand Down
Loading