Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Blocks

Blocks is an API module for managing Textile blocks

Blocks are the raw components in a thread. Think of them as an append-only log of thread updates where each update is hash-linked to its parent(s). New / recovering peers can sync history by simply traversing the hash tree.

There are several block types:

  • MERGE: 3-way merge added.
  • IGNORE: A block was ignored.
  • FLAG: A block was flagged.
  • JOIN: Peer joined.
  • ANNOUNCE: Peer set username / avatar / inbox addresses
  • LEAVE: Peer left.
  • TEXT: Text message added.
  • FILES: File(s) added.
  • COMMENT: Comment added to another block.
  • LIKE: Like added to another block.
extends

{API}

Hierarchy

  • API
    • Blocks

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

threads

threads: Threads

Methods

fileContent

  • fileContent(id: string, index?: undefined | string, path?: undefined | string): Promise<ArrayBuffer>
  • Get the decrypted file content of a file within a files block

    Parameters

    • id: string

      ID of the target block

    • Optional index: undefined | string

      Index of the target file (defaults to '0')

    • Optional path: undefined | string

      Path of the target file under the index (e.g., 'small')

    Returns Promise<ArrayBuffer>

    The file contents as an arrayBuffer (for a blob, use file.content())

fileMeta

  • fileMeta(id: string, index?: undefined | string, path?: undefined | string): Promise<ArrayBuffer>
  • Get the metadata of a file within a files block

    Parameters

    • id: string

      ID of the target block

    • Optional index: undefined | string

      Index of the target file (defaults to '0')

    • Optional path: undefined | string

      Path of the target file under the index (e.g., 'small')

    Returns Promise<ArrayBuffer>

    The file contents as an arrayBuffer (for a blob, use file.meta())

ignore

  • ignore(id: string): Promise<Block>
  • Ignores a block by its ID

    Parameters

    • id: string

      ID of the block

    Returns Promise<Block>

    The added ignore block

list

  • list(thread?: undefined | string, offset?: undefined | string, limit?: undefined | number): Promise<BlockList>
  • Get a paginated array of files.

    Parameters

    • Optional thread: undefined | string

      Thread ID (can also use ‘default’). Omit for all

    • Optional offset: undefined | string

      Offset ID to start listing from. Omit for latest

    • Optional limit: undefined | number

      List page size (default 5)

    Returns Promise<BlockList>

    An array of Block objects

meta

  • meta(id: string): Promise<Block>
  • Retrieves a block by ID

    Parameters

    • id: string

      ID of the target block

    Returns Promise<Block>

    The block object