Skip to main content
reference

GenericThread

Constructors

constructor

constructor(_threadClient: ThreadClient)

NameTypeDescription
_threadClientThreadClient

Methods

delete

Deletes Thread.

async delete()

TypeDescription
Promise<void>

getMessages

Returns a list of messages inside Thread.

async getMessages(pageIndex: number, options: ListOptions)

NameTypeDescription
pageIndexnumber
optionsListOptionsoptional options object

TypeDescription
Promise<PagingList<Message>> `PagingList<Message>

id

Returns ID of Thread.

id()

TypeDescription
string ID of current Thread

info

Fetches info about Thread.

async info()

TypeDescription
Promise<Thread> `Thread`

on

Registers an event listener for Thread message-related events.

on(eventType: T, callback: (payload: Extract<ThreadNewMessageEvent, {type: T;}> | Extract<ThreadMessageDeletedEvent, {type: T;}> | Extract<ThreadMessageUpdatedEvent, {type: T;}>)=>void)

NameTypeDescription
eventTypeTtype of event to listen for
callback(payload: Extract<ThreadNewMessageEvent, {type: T;}> | Extract<ThreadMessageDeletedEvent, {type: T;}> | Extract<ThreadMessageUpdatedEvent, {type: T;}>)=>voidcallback function to execute when the event occurs

TypeDescription
SubscribeForChannel<"threadMessages"> & { removeEventListener: ()=>void; } object containing the

sendMessage

Sends a message to Thread.

async sendMessage(newMessage: ThreadMessagePayload)

NameTypeDescription
newMessageThreadMessagePayload`ThreadMessagePayload`

TypeDescription
Promise<string> Id of new message

subscribeToMessageEvents

Subscribes to message events in given Thread: - `threadNewMessage` - `threadMessageDeleted` - `threadMessageUpdated`

async subscribeToMessageEvents()

TypeDescription
Promise<SubscribeForChannel<"threadMessages">> <'threadMessages'> `Promise<SubscribeForChannel<'threadMessages'>>

unsubscribeFromMessageEvents

Unsubscribes and removes all callbacks from message-related events in the Thread.

async unsubscribeFromMessageEvents()

TypeDescription
Promise<void> a promise that resolves with void

update

Updates Thread by overriding fields with new ones. While updating, the Bridge will check version number. Updates of Thread with different version number will be rejected. Version number is incremented after every update.

async update(updatedData: {
managers: UserWithPubKey[];
options: {
force: boolean;
forceGenerateNewKey: boolean;
};
privateMeta: Uint8Array;
publicMeta: Uint8Array;
users: UserWithPubKey[];
version: number;
})

NameTypeDescription
updatedData.managersUserWithPubKey[]list of users with permissions to modify the Thread
updatedData.options{ force: boolean; forceGenerateNewKey: boolean; }
updatedData.privateMetaUint8Array(encrypted) metadata
updatedData.publicMetaUint8Arraypublic (unencrypted) metadata
updatedData.usersUserWithPubKey[]list of users with access to the Thread
updatedData.versionnumber

TypeDescription
Promise<void> void