@@ -118,35 +118,33 @@ async function _deleteThread(thread: Doc<'threads'>) {
118118 threadIdRef .value = ' '
119119
120120 threads .value .splice (threads .value .indexOf (thread ), 1 )
121- await deleteThread (convex , { threadId: thread ._id , lockerKey: $auth .loggedIn ? undefined : thread .lockerKey })
121+ await deleteThread (convex , { threadId: thread ._id , lockerKey: $auth .loggedIn ? undefined : getLockerKey ( thread ._id ) })
122122}
123123
124124async function _shareThread(thread : Doc <' threads' >) {
125- let lockerKey = thread .lockerKey
126- if (! lockerKey ) {
125+ if (! thread .lockerKey && ! getLockerKey (thread ._id )) {
127126 const newLockerKey = getRandomLockerKey ()
128127 await threadSetLockerKey (convex , { threadId: thread ._id , newLockerKey })
129128 setLockerKey (thread ._id , newLockerKey )
130- lockerKey = newLockerKey
131129 }
132130
133- await copy (` ${window .location .origin }/chat/${thread ._id }?lockerKey=${lockerKey } ` )
131+ await copy (` ${window .location .origin }/chat/${thread ._id }?lockerKey=${getLockerKey ( thread . _id ) } ` )
134132 toast ({ description: t (' chat.toast.threadShareLinkCopied' ) })
135133}
136134
137135async function _freezeThread(thread : Doc <' threads' >) {
138136 const prevVal = thread .frozen
139137 thread .frozen = true
140138
141- await freezeThread (convex , { threadId: thread ._id , lockerKey: thread .lockerKey })
139+ await freezeThread (convex , { threadId: thread ._id , lockerKey: getLockerKey ( thread ._id ) })
142140 .catch (() => { thread .frozen = prevVal })
143141}
144142
145143async function _unfreezeThread(thread : Doc <' threads' >) {
146144 const prevVal = thread .frozen
147145 thread .frozen = undefined
148146
149- await unfreezeThread (convex , { threadId: thread ._id , lockerKey: thread .lockerKey })
147+ await unfreezeThread (convex , { threadId: thread ._id , lockerKey: getLockerKey ( thread ._id ) })
150148 .catch (() => { thread .frozen = prevVal })
151149}
152150
0 commit comments