Skip to content

Added support for local storage

Michael Hollister requested to merge feature/caching into main

Initial implementation of local storage

Main Changes:

  • Added support for a DataStore protocol for persisting Matrix objects to a custom defined object store. API consists of two protocols:
    • DataStore: A storage protocol which can persist supported types to storage, which supports both async and non-async access
    • Storable: An associatedtype indicating the key format used by the DataStore for object identification.
  • Currently supported DataStore objects that can be persisted include Session, User, Room, Credentials, ClientEvent, ClientEventWithoutRoomId.
  • Implemented a GRDBDataStore package class for local SQL DB support
  • Matrix sessions asynchronously serializes itself after every sync response if provided a DataStore
  • Added some unit tests for sanity testing GRDBDataStore implementation

Additional Changes:

  • Matrix:
    • WellKnown: Added Equitable conformance and public initializer
    • NativeImage: Added Encodable and pseudo decodable conformance (extension/subclassing not really possible for implementing full Codable protocol)
  • Session: Added Codable conformance
  • User: Added Codable conformance
  • Room:
    • Added Codable conformance
    • Changed session, type, and version constant fields to mutable fields
  • InvitedRoom: Added Codable conformance
  • MXC: Fixed/added encoding implementation
  • Added type alias for DeviceId
  • Credentials:
    • Updated implementation to match the response from the /login API endpoint
    • Added Equitable conformance
    • Added public initializer
  • UnsignedData:
    • Extracted UnsignedData type as a single type instead of having multiple types with the same implementation (e.g. ClientEvent.UnsignedData and ClientEventWithoutRoomId.UnsignedData are separate types, although implementation is identical)
    • Added public initializer
  • Added public initializers to all event types
  • Fixed RoomAvatarContent coding keys
Edited by Michael Hollister

Merge request reports