GenericThread
Constructors
constructor
constructor(_threadClient: ThreadClient)
Name | Type | Description |
---|---|---|
_threadClient | ThreadClient |
Methods
delete
Deletes Thread.
async delete()
Type | Description |
---|---|
Promise<void> |
getMessages
Returns a list of messages inside Thread.
async getMessages(pageIndex: number, options: ListOptions)
Name | Type | Description |
---|---|---|
pageIndex | number | |
options | ListOptions | optional options object |
Type | Description |
---|---|
Promise<PagingList<Message>> | `PagingList<Message> |
id
Returns ID of Thread.
id()
Type | Description |
---|---|
string | ID of current Thread |
info
Fetches info about Thread.
async info()
Type | Description |
---|---|
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)
Name | Type | Description |
---|---|---|
eventType | T | type of event to listen for |
callback | (payload: Extract<ThreadNewMessageEvent, {type: T;}> | Extract<ThreadMessageDeletedEvent, {type: T;}> | Extract<ThreadMessageUpdatedEvent, {type: T;}>)=>void | callback function to execute when the event occurs |
Type | Description |
---|---|
SubscribeForChannel<"threadMessages"> & {
removeEventListener: ()=>void;
} | object containing the |
sendMessage
Sends a message to Thread.
async sendMessage(newMessage: ThreadMessagePayload)
Name | Type | Description |
---|---|---|
newMessage | ThreadMessagePayload | `ThreadMessagePayload` |
Type | Description |
---|---|
Promise<string> | Id of new message |
subscribeToMessageEvents
Subscribes to message events in given Thread: - `threadNewMessage` - `threadMessageDeleted` - `threadMessageUpdated`
async subscribeToMessageEvents()
Type | Description |
---|---|
Promise<SubscribeForChannel<"threadMessages">> | <'threadMessages'> `Promise<SubscribeForChannel<'threadMessages'>> |
unsubscribeFromMessageEvents
Unsubscribes and removes all callbacks from message-related events in the Thread.
async unsubscribeFromMessageEvents()
Type | Description |
---|---|
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;
})
Name | Type | Description |
---|---|---|
updatedData.managers | UserWithPubKey[] | list of users with permissions to modify the Thread |
updatedData.options | {
force: boolean;
forceGenerateNewKey: boolean;
} | |
updatedData.privateMeta | Uint8Array | (encrypted) metadata |
updatedData.publicMeta | Uint8Array | public (unencrypted) metadata |
updatedData.users | UserWithPubKey[] | list of users with access to the Thread |
updatedData.version | number |
Type | Description |
---|---|
Promise<void> | void |