You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Add getSyncToken and setSyncToken to data store interface.
This allows local storage to hold onto the token across page refreshes.
This commit is contained in:
@@ -17,6 +17,22 @@ function LocalStorageStore() {
|
||||
|
||||
LocalStorageStore.prototype = {
|
||||
|
||||
/**
|
||||
* Retrieve the token to stream from.
|
||||
* @return {string} The token or null.
|
||||
*/
|
||||
getSyncToken: function() {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the token to stream from.
|
||||
* @param {string} token The token to stream from.
|
||||
*/
|
||||
setSyncToken: function(token) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Store a room in local storage.
|
||||
* @param {Room} room
|
||||
|
||||
@@ -16,10 +16,27 @@ module.exports.MatrixInMemoryStore = function MatrixInMemoryStore() {
|
||||
this.users = {
|
||||
// userId: User
|
||||
};
|
||||
this.syncToken = null;
|
||||
};
|
||||
|
||||
module.exports.MatrixInMemoryStore.prototype = {
|
||||
|
||||
/**
|
||||
* Retrieve the token to stream from.
|
||||
* @return {string} The token or null.
|
||||
*/
|
||||
getSyncToken: function() {
|
||||
return this.syncToken;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the token to stream from.
|
||||
* @param {string} token The token to stream from.
|
||||
*/
|
||||
setSyncToken: function(token) {
|
||||
this.syncToken = token;
|
||||
},
|
||||
|
||||
/**
|
||||
* Store the given room.
|
||||
* @param {Room} room The room to be stored. All properties must be stored.
|
||||
|
||||
@@ -5,15 +5,31 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Construct a stub store. This does no-ops on all store methods.
|
||||
* Construct a stub store. This does no-ops on most store methods.
|
||||
* @constructor
|
||||
*/
|
||||
function StubStore() {
|
||||
|
||||
this.fromToken = null;
|
||||
}
|
||||
|
||||
StubStore.prototype = {
|
||||
|
||||
/**
|
||||
* Get the sync token.
|
||||
* @return {string}
|
||||
*/
|
||||
getSyncToken: function() {
|
||||
return this.fromToken;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the sync token.
|
||||
* @param {string} token
|
||||
*/
|
||||
setSyncToken: function(token) {
|
||||
this.fromToken = token;
|
||||
},
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
* @param {Room} room
|
||||
|
||||
Reference in New Issue
Block a user