Class: WebStorageStore

store/webstorage~WebStorageStore

new WebStorageStore(webStore, batchSize)

Construct a web storage store, capable of storing rooms and users.
Parameters:
Name Type Description
webStore WebStorage A web storage implementation, e.g. 'window.localStorage' or 'window.sessionStorage' or a custom implementation.
batchSize integer The number of events to store per key/value (room scoped). Use -1 to store all events for a room under one key/value.
Source:
Throws:
if the supplied 'store' does not meet the Storage interface of the WebStorage API.

Methods

_syncTimeline(roomId, timelineIndices)

Sync the 'live' timeline, batching live events according to 'batchSize'.
Parameters:
Name Type Description
roomId string The room to sync the timeline.
timelineIndices Array.<String> Optional. The indices in the timeline if known already.
Source:

getFilter(userId, filterId) → (nullable) {Filter}

Retrieve a filter.
Parameters:
Name Type Description
userId string
filterId string
Source:
Returns:
A filter or null.
Type
Filter

getRoom(roomId) → (nullable) {Room}

Retrieve a room from web storage.
Parameters:
Name Type Description
roomId string
Source:
Returns:
Type
Room

getRooms() → {Array}

Get a list of all rooms from web storage.
Source:
Returns:
An empty array.
Type
Array

getRoomSummaries() → {Array}

Get a list of summaries from web storage.
Source:
Returns:
An empty array.
Type
Array

getSyncToken() → {string}

Retrieve the token to stream from.
Source:
Returns:
The token or null.
Type
string

getUser(userId) → {User}

Get a user from web storage.
Parameters:
Name Type Description
userId string
Source:
Returns:
Type
User

scrollback(room, limit) → {Array.<Object>}

Retrieve scrollback for this room. Automatically adds events to the timeline.
Parameters:
Name Type Description
room Room The matrix room to add the events to the start of the timeline.
limit integer The max number of old events to retrieve.
Source:
Returns:
An array of objects which will be at most 'limit' length and at least 0. The objects are the raw event JSON. The last element is the 'oldest' (for parity with homeserver scrollback APIs).
Type
Array.<Object>

setSyncToken(token)

Set the token to stream from.
Parameters:
Name Type Description
token string The token to stream from.
Source:

storeEvents(room, events, token, toStart)

Store events for a room. The events have already been added to the timeline.
Parameters:
Name Type Description
room Room The room to store events for.
events Array.<MatrixEvent> The events to store.
token string The token associated with these events.
toStart boolean True if these are paginated results. The last element is the 'oldest' (for parity with homeserver scrollback APIs).
Source:

storeFilter(filter)

Store a filter.
Parameters:
Name Type Description
filter Filter
Source:

storeRoom(room)

Store a room in web storage.
Parameters:
Name Type Description
room Room
Source:

storeUser(user)

Store a user in web storage.
Parameters:
Name Type Description
user User
Source: