mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 15:35:16 +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) => {
|
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();
|
||||||
|
@ -245,22 +245,22 @@ 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 thread = state.sorted.find(channel => {
|
||||||
const sealable = card.sealable && state.sealSet;
|
const { sealed, cardId, members} = channel;
|
||||||
const thread = state.sorted.find(channel => {
|
if (sealed === sealable && cardId == null && members.length === 1 && members[0].guid === card.guid) {
|
||||||
const { sealed, cardId, members} = channel;
|
return true;
|
||||||
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[]) => {
|
addTopic: async (sealed: boolean, subject: string, contacts: string[]) => {
|
||||||
const content = app.state.session.getContent()
|
const content = app.state.session.getContent()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user