fix open thread error on resize

This commit is contained in:
balzack 2024-12-16 22:38:06 -08:00
parent 32de8dab4f
commit 008dda735e
2 changed files with 15 additions and 16 deletions

View File

@ -19,8 +19,7 @@ export function Content({ textCard }: { textCard: { cardId: null|string }}) {
const openTopic = async (cardId: string) => { const openTopic = async (cardId: string) => {
setAdding(true); setAdding(true);
try { try {
const id = await actions.openTopic(cardId); await actions.openTopic(cardId);
actions.setFocus(null, id);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
showError(); showError();

View File

@ -245,9 +245,7 @@ export function useContent() {
openTopic: async (cardId: string) => { openTopic: async (cardId: string) => {
const content = app.state.session.getContent() const content = app.state.session.getContent()
const card = state.cards.find(card => card.cardId === cardId) const card = state.cards.find(card => card.cardId === cardId)
if (!card) { if (card) {
throw new Error('contact not found');
}
const sealable = card.sealable && state.sealSet; const sealable = card.sealable && state.sealSet;
const thread = state.sorted.find(channel => { const thread = state.sorted.find(channel => {
const { sealed, cardId, members} = channel; const { sealed, cardId, members} = channel;
@ -257,10 +255,12 @@ export function useContent() {
return false; return false;
}); });
if (thread) { if (thread) {
return thread.channelId; app.actions.setFocus(null, thread.channelId)
} } else {
const topic = await content.addChannel(sealable, sealable ? 'sealed' : 'superbasic', {}, [cardId]); const topic = await content.addChannel(sealable, sealable ? 'sealed' : 'superbasic', {}, [cardId]);
return topic.id; app.actions.setFocus(null, topic.id)
}
}
}, },
addTopic: async (sealed: boolean, subject: string, contacts: string[]) => { addTopic: async (sealed: boolean, subject: string, contacts: string[]) => {
const content = app.state.session.getContent() const content = app.state.session.getContent()