ContextInboxes
Provides a wrapper for functions used to manage Inboxes in given Context.
Constructors
constructor
constructor(_endpoint: Endpoint,_eventDispatcher: EventDispatcher)
Name | Type | Description |
---|---|---|
_endpoint | Endpoint | |
_eventDispatcher | EventDispatcher |
Methods
deleteEntry
Deletes an Inbox entry based on its ID.
async deleteEntry(entryId: string)
Name | Type | Description |
---|---|---|
entryId | string | ID of the entry |
Type | Description |
---|---|
Promise<void> | `Promise<InboxEntry> |
downloadFile
Downloads file from Inbox to your local environment. On platforms that support FileAPI 'showFilePicker' method it will fetch file in chunks. Otherwise, the file will be downloaded to memory first.
async downloadFile(file: {
fileId: string;
fileName: string;
progressCallback: (progress: number)=>void;
})
Name | Type | Description |
---|---|---|
file.fileId | string | File ID |
file.fileName | string | optional name that will be assigned to the file |
file.progressCallback | (progress: number)=>void | optional callback function called after fetching each file chunk |
Type | Description |
---|---|
Promise<void> |
getEntry
Gets an Inbox entry based on its ID.
async getEntry(entryId: string)
Name | Type | Description |
---|---|---|
entryId | string | ID of the entry |
Type | Description |
---|---|
Promise<InboxEntry> | `Promise<InboxEntry> |
getFileContents
Gets the content of given file. File is fetched in chunks and stored in memory.
async getFileContents(fileId: string, progressCallback: (progress: number)=>void)
Name | Type | Description |
---|---|---|
fileId | string | ID of the file to get the content from |
progressCallback | (progress: number)=>void | optional callback function called after fetching each file chunk |
Type | Description |
---|---|
Promise<Uint8Array> | content of the file |
list
Lists Inboxes the user has access to.
async list(query: {
contextId: string;
options: ListOptions;
pageIndex: number;
})
Name | Type | Description |
---|---|---|
query.contextId | string | indicates from which Context should Inboxes be fetched |
query.options | ListOptions | optional options object |
query.pageIndex | number | indicates from which page the list should start |
Type | Description |
---|---|
Promise<PagingList<Inbox>> | `PagingList<Inbox> |
new
Creates a new Inbox inside Context.
async new(newInbox: {
contextId: string;
filesConfig: FilesConfig;
managers: UserWithPubKey[];
privateMeta: Uint8Array;
publicMeta: Uint8Array;
users: UserWithPubKey[];
})
Name | Type | Description |
---|---|---|
newInbox.contextId | string | ID of the Context for the new Inbox |
newInbox.filesConfig | FilesConfig | object to override default file configuration |
newInbox.managers | UserWithPubKey[] | list of `UserWithPubKey` objects which indicates who will have access (and management rights) to the created Inbox |
newInbox.privateMeta | Uint8Array | optional (encrypted) private Inbox metadata |
newInbox.publicMeta | Uint8Array | optional (unencrypted) public Inbox metadata |
newInbox.users | UserWithPubKey[] | list of `UserWithPubKey` objects which indicates who will have access to the created Inbox |
Type | Description |
---|---|
Promise<string> | Created Inbox ID |
on
Registers an event listener for Inbox-related events.
on(eventType: T, callback: (payload: Extract<InboxCreatedEvent, {type: T;}> | Extract<InboxUpdatedEvent, {type: T;}> | Extract<InboxDeletedEvent, {type: T;}>)=>void)
Name | Type | Description |
---|---|---|
eventType | T | type of event to listen for |
callback | (payload: Extract<InboxCreatedEvent, {type: T;}> | Extract<InboxUpdatedEvent, {type: T;}> | Extract<InboxDeletedEvent, {type: T;}>)=>void | callback function to execute when the event occurs |
Type | Description |
---|---|
SubscribeForChannel<"inbox"> & {
removeEventListener: ()=>void;
} | object containing the |
subscribeForInboxEvents
Subscribes to events related to Inboxes: - `inboxCreated` - `inboxDeleted` - `inboxStatsChanged` - `inboxUpdated`
async subscribeForInboxEvents()
Type | Description |
---|---|
Promise<SubscribeForChannel<"inbox">> | <'inbox'> `Promise<SubscribeForChannel<'inbox'>> |
unsubscribeFromInboxEvents
Unsubscribes and removes all registered callbacks for events related to Inboxes
async unsubscribeFromInboxEvents()
Type | Description |
---|---|
Promise<void> |