Files
speckle-server/packages/frontend-2/lib/common/helpers/debugging.ts
T
Kristaps Fabians Geikins 9427686d42 fix(fe2): various follow mode & thread viewer state sync fixes & improvements (#1595)
* fix(fe2): unfollow on camera move

* WIP new state hydration function

* WIP sync state

* minor cleanup

* fix coloring not being tracked

* fix for post thread close camera pos restore

* supporting duplicate users

* preventing guest commenting + state reset fixes

* fixed guests not receiving viewer comment updates

* post-thread creation opens new thread

* removing gap between 'X is typing' and bubble appearing

* reset filters will also reset colors now

* fixed thread full context

* camera reset fix

* thread reset fix

* fixed router concurrency issues

* followed user avatar fix

* TONS OF DEBUGGING FOR ROUTER QUEUING

* removing queued routing debugging stuff + disabling spotlight cancelation

* WIP async URL updates

* missing authLogger fixed

* fix for broken projection

* fix for bubbles positions not updating correctly

* queued routing cleanup

* fixed spotlight mode disabling unnecessarily

* added back stoplight stop on ctrl

* undid spotlight debugging
2023-05-29 15:20:32 +03:00

33 lines
853 B
TypeScript

/**
* Wrap refs with writable computeds that output where reads/writes are coming from
*/
export function wrapRefWithTracking<R extends Ref<unknown>>(
ref: R,
name: string,
options?: Partial<{
writesOnly: boolean
readsOnly: boolean
}>
): R {
const { writesOnly, readsOnly } = options || {}
const getTrace = () => (new Error('Trace:').stack || '').substring(7)
return computed({
get: () => {
if (!writesOnly) {
console.debug(`debugging: '${name}' read`, ref.value, getTrace())
}
return ref.value
},
set: (newVal) => {
if (!readsOnly) {
console.debug(`debugging: '${name}' written to`, newVal, getTrace())
}
ref.value = newVal
}
// hiding the real type so that you don't have to re-type everything that relies on the ref being a ref
}) as unknown as R
}