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) => {
setAdding(true);
try {
const id = await actions.openTopic(cardId);
actions.setFocus(null, id);
await actions.openTopic(cardId);
} catch (err) {
console.log(err);
showError();

View File

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