1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-09-03 08:42:03 +03:00

Add scrollback to store interface

This commit is contained in:
Kegan Dougal
2015-06-30 11:48:49 +01:00
parent 5d5d76d154
commit aaecda53d6
3 changed files with 86 additions and 62 deletions

View File

@@ -87,6 +87,17 @@ module.exports.MatrixInMemoryStore.prototype = {
*/ */
getUser: function(userId) { getUser: function(userId) {
return this.users[userId] || null; return this.users[userId] || null;
},
/**
* Retrieve scrollback for this room.
* @param {Room} room The matrix room
* @param {integer} limit The max number of old events to retrieve.
* @return {Array<Object>} An array of objects which will be at most 'limit'
* length and at least 0. The objects are the raw event JSON.
*/
scrollback: function(room, limit) {
return [];
} }
// TODO // TODO

View File

@@ -76,6 +76,16 @@ StubStore.prototype = {
*/ */
getUser: function(userId) { getUser: function(userId) {
return null; return null;
},
/**
* No-op.
* @param {Room} room
* @param {integer} limit
* @return {Array}
*/
scrollback: function(room, limit) {
return [];
} }
// TODO // TODO

View File

@@ -139,77 +139,80 @@ function WebStorageStore(store, batchSize) {
} }
} }
WebStorageStore.prototype = {
/** /**
* Retrieve the token to stream from. * Retrieve the token to stream from.
* @return {string} The token or null. * @return {string} The token or null.
*/ */
getSyncToken: function() { WebStorageStore.prototype.getSyncToken = function() {
return null; return this.store.getItem("sync_token");
}, };
/** /**
* Set the token to stream from. * Set the token to stream from.
* @param {string} token The token to stream from. * @param {string} token The token to stream from.
*/ */
setSyncToken: function(token) { WebStorageStore.prototype.setSyncToken = function(token) {
this.store.setItem("sync_token", token);
};
}, /**
* Store a room in web storage.
* @param {Room} room
*/
WebStorageStore.prototype.storeRoom = function(room) {
};
/** /**
* Store a room in web storage. * Retrieve a room from web storage.
* @param {Room} room * @param {string} roomId
*/ * @return {null}
storeRoom: function(room) { */
}, WebStorageStore.prototype.getRoom = function(roomId) {
return null;
};
/** /**
* Retrieve a room from web storage. * Get a list of all rooms from web storage.
* @param {string} roomId * @return {Array} An empty array.
* @return {null} */
*/ WebStorageStore.prototype.getRooms = function() {
getRoom: function(roomId) { return [];
return null; };
},
/** /**
* Get a list of all rooms from web storage. * Get a list of summaries from web storage.
* @return {Array} An empty array. * @return {Array} An empty array.
*/ */
getRooms: function() { WebStorageStore.prototype.getRoomSummaries = function() {
return []; return [];
}, };
/** /**
* Get a list of summaries from web storage. * Store a user in web storage.
* @return {Array} An empty array. * @param {User} user
*/ */
getRoomSummaries: function() { WebStorageStore.prototype.storeUser = function(user) {
return []; };
},
/** /**
* Store a user in web storage. * Get a user from web storage.
* @param {User} user * @param {string} userId
*/ * @return {null}
storeUser: function(user) { */
}, WebStorageStore.prototype.getUser = function(userId) {
return null;
};
/** /**
* Get a user from web storage. * Retrieve scrollback for this room.
* @param {string} userId * @param {Room} room The matrix room
* @return {null} * @param {integer} limit The max number of old events to retrieve.
*/ * @return {Array<Object>} An array of objects which will be at most 'limit'
getUser: function(userId) { * length and at least 0. The objects are the raw event JSON.
return null; */
} WebStorageStore.prototype.scrollback = function(room, limit) {
return [];
// TODO
//setMaxHistoryPerRoom: function(maxHistory) {},
// TODO
//reapOldMessages: function() {},
}; };
/** Web Storage Store class. */ /** Web Storage Store class. */