Model's Base Class.

Hierarchy (view full)

Constructors

Properties

groupIdHash: SHA256IdHash<Group>
name: string = 'unnamed group'
onUpdated: OEvent<((added?: SHA256IdHash<Person>[], removed?: SHA256IdHash<Person>[]) => void)> = ...
persons: SHA256IdHash<Person>[] = []
picture?: ArrayBuffer
profileIdHash: SHA256IdHash<GroupProfile>
state: StateMachine<"Uninitialised" | "Initialised", "shutdown" | "init">

Accessors

  • get internalGroupName(): string
  • Returns the name of the loaded Group object.

    Returns string

    if nothing was loaded

Methods

  • Returns whether this model has data loaded.

    If this returns false, then the 'internalGroupName' property will throw and group members list and name and picture will be empty / undefined.

    Returns boolean

  • Save the profile to disk and load the latest version.

    Why is there no pure save() function? The cause are CRDTs. The object that is eventually written to disk might differ from the current state of this instance. This happens when new data was received via chum since the last load. This means that we don't have a hash representing the current state.

    TODO: It is possible to write the intermediary state and obtain a hash. So we can implement a pure save() function. But this requires the lower levels to write the top level object of the tree and return the corresponding hash to the caller. The storeVersionedObjectCRDT and the plan interfaces don't support that right now in a easy to grasp way.

    Returns Promise<void>

  • Construct a new GroupModel with the latest version loaded.

    Parameters

    • groupIdHash: SHA256IdHash<Group>

    Returns Promise<default>

  • Construct from internal group name.

    Internal group name is the name parameter of the Group object.

    Parameters

    • groupName: string

    Returns Promise<default>

  • Create a group and profile if they do not exist.

    If it already exists, it will simply return the existing group.

    Parameters

    • OptionalgroupName: string

      Name if not given the internal name will be random, and the profile name will be 'unnamed group'

    Returns Promise<default>

    The latest version of the group or an empty group.