Skip to content

Commit

Permalink
[WBX-153] Persist Comment Visibility (specklesystems#2032)
Browse files Browse the repository at this point in the history
* Add discussionLoadedVersionOnly cookie - defaulted to true

* Updates from CR

* Revert change

* Updates

* Remove unneeded watch

* Updates
  • Loading branch information
andrewwallacespeckle authored Feb 13, 2024
1 parent 48440e5 commit 18c30b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ const {
const showVisibilityOptions = ref(false)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const loadedVersionsOnly = computed({
get: () =>
threadFilters.value.loadedVersionsOnly || false ? 'loadedVersionsOnly' : undefined,
Expand Down
19 changes: 18 additions & 1 deletion packages/frontend-2/lib/viewer/composables/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
InjectableViewerStateKey,
useSetupViewerScope
} from '~/lib/viewer/composables/setup/core'
import { useSynchronizedCookie } from '~~/lib/common/composables/reactiveCookie'

export type LoadedModel = NonNullable<
Get<ViewerLoadedResourcesQuery, 'project.models.items[0]'>
Expand Down Expand Up @@ -438,7 +439,14 @@ function setupResourceRequest(state: InitialSetupState): InitialStateWithRequest
asyncRead: false
})

const threadFilters = ref({} as Omit<ProjectCommentsFilter, 'resourceIdString'>)
const discussionLoadedVersionOnly = useSynchronizedCookie<boolean>(
'discussionLoadedVersionOnly',
{
default: () => true
}
)

const threadFilters = ref({ loadedVersionsOnly: discussionLoadedVersionOnly.value })

const switchModelToVersion = async (modelId: string, versionId?: string) => {
const resourceArr = resources.value.slice()
Expand Down Expand Up @@ -466,6 +474,15 @@ function setupResourceRequest(state: InitialSetupState): InitialStateWithRequest
}
}

watch(
() => threadFilters.value.loadedVersionsOnly,
(newVal, oldVal) => {
if (newVal !== oldVal && newVal !== discussionLoadedVersionOnly.value) {
discussionLoadedVersionOnly.value = newVal
}
}
)

return {
...state,
resources: {
Expand Down

0 comments on commit 18c30b8

Please sign in to comment.