mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 10:05:19 +00:00
fix open thread error on resize
This commit is contained in:
parent
32de8dab4f
commit
008dda735e
@ -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();
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user