mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 18:15:19 +00:00
implementing focus module
This commit is contained in:
parent
55d66dc9e3
commit
9fcbcafdaa
@ -53,7 +53,8 @@ export function useConversation() {
|
||||
add: async (file: File) => {
|
||||
const { focus } = app.state;
|
||||
if (focus) {
|
||||
const asset = { name: 'image', extension: file.name.split('.').pop(), mimeType: file.type, hosting: [{ mode: HostingMode.Thumb, context: 'thumb' }, { mode: HostingMode.Copy, context: 'image' }] };
|
||||
console.log("UPLOAD", file);
|
||||
const asset = { source: file, name: 'image', extension: file.name.split('.').pop(), mimeType: file.type, hosting: [{ mode: HostingMode.Thumb, context: 'thumb' }, { mode: HostingMode.Copy, context: 'image' }] };
|
||||
const topicId = await focus.addTopic(false, 'superbasictopic', (assets: {assetId: string, context: any}[])=> ({ text: 'sdkasset' }), [asset]);
|
||||
}
|
||||
},
|
||||
|
13024
app/client/web/yarn.lock
13024
app/client/web/yarn.lock
File diff suppressed because it is too large
Load Diff
@ -59,6 +59,9 @@ export class FocusModule implements Focus {
|
||||
this.topicEntries = new Map<string, { item: TopicItem; topic: Topic }>();
|
||||
this.markers = new Set<string>();
|
||||
|
||||
console.log("FOCUS:", cardId, channelId, connection);
|
||||
|
||||
|
||||
this.cacheView = null;
|
||||
this.storeView = { revision: null, marker: null };
|
||||
this.syncing = true;
|
||||
@ -219,7 +222,7 @@ export class FocusModule implements Focus {
|
||||
}
|
||||
}
|
||||
|
||||
private uploadFile(path: string, transforms: string[], topicId: string, progress: (percent: number)=>boolean): Promise<{assetId: string, transform: string}[]> {
|
||||
private uploadFile(source: any, transforms: string[], topicId: string, progress: (percent: number)=>boolean): Promise<{assetId: string, transform: string}[]> {
|
||||
const { cardId, channelId, connection } = this;
|
||||
if (!connection) {
|
||||
throw new Error('disconnected from channel');
|
||||
@ -228,7 +231,7 @@ export class FocusModule implements Focus {
|
||||
const params = `${cardId ? 'contact' : 'agent'}=${token}&transforms=${encodeURIComponent(JSON.stringify(transforms))}`
|
||||
const url = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/topics/${topicId}/assets?${params}`
|
||||
const formData = new FormData();
|
||||
formData.append('asset', {uri: path, name: 'asset', type: 'application/octent-stream'});
|
||||
formData.append('asset', source);
|
||||
|
||||
console.log("USING URL", url);
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import { ChannelEntity } from '../entities';
|
||||
|
||||
export async function getChannels(node: string, secure: boolean, token: string, revision: number, types: string[]): Promise<ChannelEntity[]> {
|
||||
const params = (revision ? `&revision=${revision}` : '') + `&types=${encodeURIComponent(JSON.stringify(types))}`;
|
||||
const params = (revision ? `&channelRevision=${revision}` : '') + `&types=${encodeURIComponent(JSON.stringify(types))}`;
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels?agent=${token}${params}`;
|
||||
const channels = await fetchWithTimeout(endpoint, { method: 'GET' });
|
||||
checkResponse(channels.status);
|
||||
|
@ -2,8 +2,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setChannelTopicSubject(node: string, secure: boolean, token: string, channelId: string, topicId: string, dataType: string, data: any) {
|
||||
const subject = { data: JSON.stringify(data), dataType };
|
||||
const endpoint = `http${secure ? 's' : '' }://${node}/content/channels/${channelId}/topics?agent=${token}&confirm=true`;
|
||||
const { status } = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(data) });
|
||||
const endpoint = `http${secure ? 's' : '' }://${node}/content/channels/${channelId}/topics/${topicId}/subject?agent=${token}&confirm=true`;
|
||||
const { status } = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(subject) });
|
||||
checkResponse(status);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setContactChannelTopicSubject(node: string, secure: boolean, guidToken: string, channelId: topicId: string, dataType: string, data: any) {
|
||||
const subject = { data: JSON.stringify(data), dataType };
|
||||
const endpoint = `http${secure ? 's' : '' }://${node}/content/channels/${channelId}/topics?contact=${guidToken}&confirm=true`;
|
||||
const { status } = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(data) });
|
||||
const endpoint = `http${secure ? 's' : '' }://${node}/content/channels/${channelId}/topics/${topicId}/subject?contact=${guidToken}&confirm=true`;
|
||||
const { status } = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(subject) });
|
||||
checkResponse(status);
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,7 @@ export type AssetSource = {
|
||||
name: string;
|
||||
mimeType: string;
|
||||
extension: string;
|
||||
source: any;
|
||||
hosting: {mode: HostingMode, context: any, data?: string, position?: number, size?: number}[],
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user