({
state: newState,
title: newTitle,
}: {
state?: ThreadState;
title?: string;
})
| 608 | }; |
| 609 | |
| 610 | const updateThread = ({ |
| 611 | state: newState, |
| 612 | title: newTitle, |
| 613 | }: { |
| 614 | state?: ThreadState; |
| 615 | title?: string; |
| 616 | }) => { |
| 617 | if (!currentThreadId) { |
| 618 | return; |
| 619 | } |
| 620 | const options: { state?: ThreadState; title?: string } = {}; |
| 621 | if (newState) { |
| 622 | options.state = newState; |
| 623 | } |
| 624 | if (newTitle) { |
| 625 | options.title = newTitle; |
| 626 | } |
| 627 | setThreads((threads) => { |
| 628 | return threads.map((thread) => { |
| 629 | if (thread.id === currentThreadId) { |
| 630 | return { |
| 631 | ...thread, |
| 632 | ...options, |
| 633 | }; |
| 634 | } |
| 635 | return thread; |
| 636 | }); |
| 637 | }); |
| 638 | return api |
| 639 | .updateThread({ |
| 640 | accountId: settings.communityId, |
| 641 | id: currentThreadId, |
| 642 | ...options, |
| 643 | }) |
| 644 | .catch((_) => { |
| 645 | Toast.error('Failed to close the thread.'); |
| 646 | }); |
| 647 | }; |
| 648 | |
| 649 | const editThread = ({ |
| 650 | id, |
nothing calls this directly
no test coverage detected