(threadId: string)
| 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 |
nothing calls this directly
no test coverage detected