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

Show resolved comment indicators #4677

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 1 addition & 15 deletions editor/src/components/canvas/controls/comment-indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ const CommentIndicatorsInner = React.memo(() => {
{temporaryIndicatorData != null ? (
<CommentIndicatorUI
position={temporaryIndicatorData.position}
opacity={1}
resolved={false}
bgColor={temporaryIndicatorData.bgColor}
fgColor={temporaryIndicatorData.fgColor}
Expand All @@ -181,7 +180,6 @@ CommentIndicatorsInner.displayName = 'CommentIndicatorInner'

interface CommentIndicatorUIProps {
position: WindowPoint
opacity: number
resolved: boolean
bgColor: string
fgColor: string
Expand All @@ -192,24 +190,13 @@ interface CommentIndicatorUIProps {
}

export const CommentIndicatorUI = React.memo<CommentIndicatorUIProps>((props) => {
const {
position,
bgColor,
fgColor,
avatarUrl,
avatarInitials,
opacity,
resolved,
isActive,
read,
} = props
const { position, bgColor, fgColor, avatarUrl, avatarInitials, resolved, isActive, read } = props

function getIndicatorStyle() {
const base: Interpolation<Theme> = {
position: 'fixed',
top: position.y + 3,
left: position.x - 3,
opacity: opacity,
filter: resolved ? 'grayscale(1)' : undefined,
width: IndicatorSize,
height: IndicatorSize,
Expand Down Expand Up @@ -339,7 +326,6 @@ const CommentIndicator = React.memo(({ thread }: CommentIndicatorProps) => {
(isActive || !hovered) && !dragging,
<CommentIndicatorUI
position={position}
opacity={isOnAnotherRoute || thread.metadata.resolved ? 0 : 1}
resolved={thread.metadata.resolved}
bgColor={color.background}
fgColor={color.foreground}
Expand Down
31 changes: 13 additions & 18 deletions editor/src/core/commenting/comment-hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,37 +233,32 @@ export function useResolveThread() {
}

export function useActiveThreads() {
const { threads: unresolvedThreads } = useUnresolvedThreads()
const { threads: resolvedThreads } = useResolvedThreads()
const { threads } = useThreads()
const showResolved = useEditorState(
Substores.restOfEditor,
(store) => store.editor.showResolvedThreads,
'useActiveThreads showResolved',
)
if (!showResolved) {
return unresolvedThreads
return threads.filter((t) => !t.metadata.resolved)
}
return [...unresolvedThreads, ...resolvedThreads]
return threads
}

export function useResolvedThreads() {
return useThreads({
query: {
metadata: {
resolved: true,
},
},
})
const threads = useThreads()
return {
...threads,
threads: threads.threads.filter((t) => t.metadata.resolved),
}
}

export function useUnresolvedThreads() {
return useThreads({
query: {
metadata: {
resolved: false,
},
},
})
const threads = useThreads()
return {
...threads,
threads: threads.threads.filter((t) => !t.metadata.resolved),
}
}

export function useSetThreadReadStatusOnMount(thread: ThreadData<ThreadMetadata> | null) {
Expand Down
Loading