ts-algochat
    Preparing search index...

    Class Conversation

    Represents a conversation with another user

    Provides helper methods for accessing messages, merging updates, and tracking conversation state.

    Index

    Constructors

    • Creates a new Conversation

      Parameters

      • participant: string

        Algorand address of the other party

      • OptionalparticipantPublicKey: Uint8Array<ArrayBufferLike>

        X25519 encryption public key (if known)

      • messages: Message[] = []

        Initial messages

      • OptionallastFetchedRound: number

        Last blockchain round that was fetched

      Returns Conversation

    Properties

    lastFetchedRound?: number

    Last blockchain round that was fetched

    participant: string

    Algorand address of the other party

    participantPublicKey?: Uint8Array<ArrayBufferLike>

    X25519 encryption public key (if known)

    Accessors

    Methods

    • Appends a message to the conversation

      If the message already exists (by ID), it is ignored. Messages are kept sorted by timestamp.

      Parameters

      Returns boolean

      true if message was added, false if it already existed

    • Checks if a message exists

      Parameters

      • id: string

        Transaction ID to check

      Returns boolean

    • Merges multiple messages into the conversation

      Duplicates are ignored. Messages are sorted after merge.

      Parameters

      • messages: Message[]

        Messages to merge

      Returns number

      Number of new messages added

    • Updates the last fetched round

      Parameters

      • round: number

        The round number

      Returns void

    • Updates the participant's public key

      Parameters

      • publicKey: Uint8Array

        The new public key

      Returns void

    • Converts to a plain object for serialization

      Returns {
          lastFetchedRound?: number;
          messages: Message[];
          participant: string;
          participantPublicKey?: string;
      }

    • Creates a Conversation from a plain object

      Parameters

      • data: {
            lastFetchedRound?: number;
            messages: (Message | { timestamp: string; [key: string]: unknown })[];
            participant: string;
            participantPublicKey?: string;
        }

      Returns Conversation