mirror of
https://github.com/balzack/databag.git
synced 2025-04-29 04:55:18 +00:00
pulling ids from focus object
This commit is contained in:
parent
c0319b0864
commit
034aff8c60
@ -33,7 +33,7 @@ export function useContent() {
|
|||||||
filter: '',
|
filter: '',
|
||||||
topic: '',
|
topic: '',
|
||||||
sealSet: false,
|
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) => {
|
const compare = (a: Card, b: Card) => {
|
||||||
@ -164,8 +164,8 @@ export function useContent() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (app.state.focus) {
|
if (app.state.focus) {
|
||||||
const { cardId, channelId } = app.state.focus;
|
const focused = app.state.focus.getFocused();
|
||||||
updateState({ focused: { cardId, channelId } });
|
updateState({ focused });
|
||||||
} else {
|
} else {
|
||||||
updateState({ focused: null });
|
updateState({ focused: null });
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ export function useAppContext() {
|
|||||||
const sdk = useRef(databag)
|
const sdk = useRef(databag)
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
session: null as null | Session,
|
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
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@ -84,8 +84,8 @@ export function useAppContext() {
|
|||||||
},
|
},
|
||||||
setFocus: (cardId: string | null, channelId: string) => {
|
setFocus: (cardId: string | null, channelId: string) => {
|
||||||
if (state.session) {
|
if (state.session) {
|
||||||
const thread = state.session.setFocus(cardId, channelId);
|
const focus = state.session.setFocus(cardId, channelId);
|
||||||
updateState({ focus: {cardId, channelId, thread} });
|
updateState({ focus });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clearFocus: () => {
|
clearFocus: () => {
|
||||||
|
@ -34,7 +34,7 @@ export function useConversation() {
|
|||||||
}, [display.state])
|
}, [display.state])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const focus = app.state.focus?.thread;
|
const focus = app.state.focus;
|
||||||
const { contact, identity } = app.state.session || { };
|
const { contact, identity } = app.state.session || { };
|
||||||
if (focus && contact && identity) {
|
if (focus && contact && identity) {
|
||||||
const setTopics = (topics: Topic[]) => {
|
const setTopics = (topics: Topic[]) => {
|
||||||
@ -87,7 +87,7 @@ export function useConversation() {
|
|||||||
app.actions.clearFocus();
|
app.actions.clearFocus();
|
||||||
},
|
},
|
||||||
more: async () => {
|
more: async () => {
|
||||||
const focus = app.state.focus?.thread;
|
const focus = app.state.focus;
|
||||||
if (focus) {
|
if (focus) {
|
||||||
if (!state.loadingMore) {
|
if (!state.loadingMore) {
|
||||||
updateState({ loadingMore: true });
|
updateState({ loadingMore: true });
|
||||||
@ -99,7 +99,7 @@ export function useConversation() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
add: async (file: File) => {
|
add: async (file: File) => {
|
||||||
const focus = app.state.focus?.thread;
|
const focus = app.state.focus;
|
||||||
if (focus) {
|
if (focus) {
|
||||||
const asset = {
|
const asset = {
|
||||||
name: 'topic',
|
name: 'topic',
|
||||||
|
@ -123,6 +123,8 @@ export interface Attribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Focus {
|
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>;
|
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>;
|
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>;
|
removeTopic(topicId: string): Promise<void>;
|
||||||
|
@ -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[] } {
|
private getTopicData(item: TopicItem): { data: any, assets: AssetItem[] } {
|
||||||
const topicDetail = item.detail.sealed ? item.unsealedDetail : item.detail.data;
|
const topicDetail = item.detail.sealed ? item.unsealedDetail : item.detail.data;
|
||||||
const { revision } = item.detail;
|
const { revision } = item.detail;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user