From 1b6cab28bc753a130235d71f68c1c3778b27d40a Mon Sep 17 00:00:00 2001 From: balzack Date: Mon, 7 Oct 2024 07:57:41 -0700 Subject: [PATCH] matching focus api changes --- app/sdk/src/api.ts | 4 ++-- app/sdk/src/content.ts | 17 ++++++++++++++--- app/sdk/src/session.ts | 7 ++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/sdk/src/api.ts b/app/sdk/src/api.ts index 9c77420c..f5f7aee6 100644 --- a/app/sdk/src/api.ts +++ b/app/sdk/src/api.ts @@ -10,8 +10,8 @@ export interface Session { getStream(): Stream; getRing(): Ring; - addFocus(cardId: string | null, channelId: string): Focus; - removeFocus(focus: Focus): void; + setFocus(cardId: string | null, channelId: string): Focus; + clearFocus(): void; addStatusListener(ev: (status: string) => void): void; removeStatusListener(ev: (status: string) => void): void; diff --git a/app/sdk/src/content.ts b/app/sdk/src/content.ts index 59e772fb..d64e9164 100644 --- a/app/sdk/src/content.ts +++ b/app/sdk/src/content.ts @@ -1,10 +1,13 @@ import { EventEmitter } from "eventemitter3"; -import type { Content, Settings, Logging } from "./api"; +import type { Content, Settings, Logging, Focus } from "./api"; import type { Channel, Topic, Asset, Tag, Participant } from "./types"; import { Store } from "./store"; +import { Crypto } from "./crypto"; export class ContentModule implements Content { private log: Logging; + private store: Store; + private crypto: Crypto | null; private guid: string; private token: string; private node: string; @@ -12,12 +15,14 @@ export class ContentModule implements Content { private settings: Settings; private emitter: EventEmitter; - constructor(log: Logging, settings: Settings, store: Store, guid: string, token: string, node: string, secure: boolean) { + constructor(log: Logging, settings: Settings, store: Store, crypto: Crypto | null, guid: string, token: string, node: string, secure: boolean) { this.guid = guid; this.token = token; this.node = node; this.secure = secure; this.log = log; + this.store = store; + this.crypto = crypto; this.settings = settings; this.emitter = new EventEmitter(); } @@ -144,9 +149,15 @@ export class ContentModule implements Content { public async clearUnreadChannel(channelId: string): Promise {} + public async setFocus(chanenlId: string): Focus { + return new FocusModule(this.log, this.store, this.crypto, null, channelId, null); + } + + public async clearFocus() {} + public async addParticipantAccess(channelId: string, name: string): Promise { return { id: "", guid: "", name: "", server: "", token: "" }; } public async removeParticipantAccess(channelId: string, repeaterId: string): Promise {} -} +i} diff --git a/app/sdk/src/session.ts b/app/sdk/src/session.ts index 595957d3..e5349562 100644 --- a/app/sdk/src/session.ts +++ b/app/sdk/src/session.ts @@ -156,11 +156,12 @@ export class SessionModule implements Session { return this.ring; } - public addFocus(cardId: string | null, channelId: string): Focus { + public setFocus(cardId: string | null, channelId: string): Focus { return new FocusModule(this.log, this.identity, this.contact, this.content, this.store, cardId, channelId); } - public removeFocus(focus: Focus): void { - focus.blur(); + public clearFocus(): void { + this.contact.clearFocus(); + this.content.clearFocus(); } }