MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / pinThread

Function pinThread

apps/web/ui/ChannelView/index.tsx:352–384  ·  view source on GitHub ↗
(threadId: string)

Source from the content-addressed store, hash-verified

350 }
351
352 async function pinThread(threadId: string) {
353 const thread =
354 threads.find(({ id }) => id === threadId) ||
355 pinnedThreads.find(({ id }) => id === threadId);
356 if (!thread) {
357 return;
358 }
359 const newPinned = !thread.pinned;
360 setThreads((threads) => {
361 return threads.map((thread) => {
362 if (thread.id === threadId) {
363 return { ...thread, pinned: newPinned };
364 }
365 return thread;
366 });
367 });
368 setPinnedThreads((pinnedThreads) => {
369 if (newPinned) {
370 return [...pinnedThreads, { ...thread, pinned: true }];
371 } else {
372 return pinnedThreads.filter(({ id }) => id !== threadId);
373 }
374 });
375 return api
376 .updateThread({
377 accountId: currentCommunity.id,
378 id: thread.id,
379 pinned: newPinned,
380 })
381 .catch((_) => {
382 Toast.error('Failed to pin the thread.');
383 });
384 }
385
386 async function starThread(threadId: string) {
387 return api

Callers

nothing calls this directly

Calls 4

mapMethod · 0.80
updateThreadMethod · 0.65
errorMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected