pulling ids from focus object

This commit is contained in:
balzack 2024-12-10 19:54:47 -08:00
parent c0319b0864
commit 034aff8c60
5 changed files with 16 additions and 9 deletions

View File

@ -33,7 +33,7 @@ export function useContent() {
filter: '',
topic: '',
sealSet: false,
focused: null as null|{cardId: null|string, channelId},
focused: null as null|{cardId: null|string, channelId: string},
})
const compare = (a: Card, b: Card) => {
@ -164,8 +164,8 @@ export function useContent() {
useEffect(() => {
if (app.state.focus) {
const { cardId, channelId } = app.state.focus;
updateState({ focused: { cardId, channelId } });
const focused = app.state.focus.getFocused();
updateState({ focused });
} else {
updateState({ focused: null });
}

View File

@ -10,7 +10,7 @@ export function useAppContext() {
const sdk = useRef(databag)
const [state, setState] = useState({
session: null as null | Session,
focus: null as null | { cardId: null | string, channelId: string, thread: Focus },
focus: null as null | Focus,
})
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@ -84,8 +84,8 @@ export function useAppContext() {
},
setFocus: (cardId: string | null, channelId: string) => {
if (state.session) {
const thread = state.session.setFocus(cardId, channelId);
updateState({ focus: {cardId, channelId, thread} });
const focus = state.session.setFocus(cardId, channelId);
updateState({ focus });
}
},
clearFocus: () => {

View File

@ -34,7 +34,7 @@ export function useConversation() {
}, [display.state])
useEffect(() => {
const focus = app.state.focus?.thread;
const focus = app.state.focus;
const { contact, identity } = app.state.session || { };
if (focus && contact && identity) {
const setTopics = (topics: Topic[]) => {
@ -87,7 +87,7 @@ export function useConversation() {
app.actions.clearFocus();
},
more: async () => {
const focus = app.state.focus?.thread;
const focus = app.state.focus;
if (focus) {
if (!state.loadingMore) {
updateState({ loadingMore: true });
@ -99,7 +99,7 @@ export function useConversation() {
}
},
add: async (file: File) => {
const focus = app.state.focus?.thread;
const focus = app.state.focus;
if (focus) {
const asset = {
name: 'topic',

View File

@ -123,6 +123,8 @@ export interface Attribute {
}
export interface Focus {
getFocused(): {cardId: null|string, channelId: string};
addTopic(sealed: boolean, type: string, subject: (assets: {assetId: string, appId: string}[])=>any, assets: AssetSource[], progress: (percent: number)=>boolean): Promise<string>;
setTopicSubject(topicId: string, type: string, subject: (assets: {assetId: string, appId: string}[])=>any, files: AssetSource[], progress: (percent: number)=>boolean): Promise<void>;
removeTopic(topicId: string): Promise<void>;

View File

@ -913,6 +913,11 @@ export class FocusModule implements Focus {
});
}
public getFocused() {
const { cardId, channelId } = this;
return { cardId, channelId };
}
private getTopicData(item: TopicItem): { data: any, assets: AssetItem[] } {
const topicDetail = item.detail.sealed ? item.unsealedDetail : item.detail.data;
const { revision } = item.detail;