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
Fix up stylistic warnings.
This commit is contained in:
@@ -34,5 +34,9 @@ matrixcs.request(function(opts, callback) {
|
|||||||
});
|
});
|
||||||
return defer.promise;
|
return defer.promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export a modified matrix library with Promise support.
|
||||||
|
*/
|
||||||
module.exports = matrixcs;
|
module.exports = matrixcs;
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ var init = function(exports){
|
|||||||
* @param {String} type the type of the state events to be returned (optional)
|
* @param {String} type the type of the state events to be returned (optional)
|
||||||
* @param {String} stateKey the stateKey of the state events to be returned
|
* @param {String} stateKey the stateKey of the state events to be returned
|
||||||
* (optional, requires type to be specified)
|
* (optional, requires type to be specified)
|
||||||
* @return {MatrixEvent[]} an array of MatrixEvents from the store, filtered by roomid, type and state key.
|
* @return {MatrixEvent[]} an array of MatrixEvents from the store,
|
||||||
|
* filtered by roomid, type and state key.
|
||||||
*/
|
*/
|
||||||
getStateEvents: function(roomId, type, stateKey) {
|
getStateEvents: function(roomId, type, stateKey) {
|
||||||
var stateEvents = [];
|
var stateEvents = [];
|
||||||
@@ -160,7 +161,9 @@ var init = function(exports){
|
|||||||
if (this.rooms[roomId].state.hasOwnProperty(type)) {
|
if (this.rooms[roomId].state.hasOwnProperty(type)) {
|
||||||
for (stateKey in this.rooms[roomId].state[type]) {
|
for (stateKey in this.rooms[roomId].state[type]) {
|
||||||
if (this.rooms[roomId].state[type].hasOwnProperty(stateKey)) {
|
if (this.rooms[roomId].state[type].hasOwnProperty(stateKey)) {
|
||||||
stateEvents.push(this.rooms[roomId].state[type][stateKey]);
|
stateEvents.push(
|
||||||
|
this.rooms[roomId].state[type][stateKey]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +189,8 @@ var init = function(exports){
|
|||||||
* @param {String} roomId the Room ID whose state is to be returned
|
* @param {String} roomId the Room ID whose state is to be returned
|
||||||
* @param {String} type the type of the state events to be returned
|
* @param {String} type the type of the state events to be returned
|
||||||
* @param {String} stateKey the stateKey of the state events to be returned
|
* @param {String} stateKey the stateKey of the state events to be returned
|
||||||
* @return {MatrixEvent} a single MatrixEvent from the store, filtered by roomid, type and state key.
|
* @return {MatrixEvent} a single MatrixEvent from the store, filtered
|
||||||
|
* by roomid, type and state key.
|
||||||
*/
|
*/
|
||||||
getStateEvent: function(roomId, type, stateKey) {
|
getStateEvent: function(roomId, type, stateKey) {
|
||||||
return this.rooms[roomId].state[type][stateKey];
|
return this.rooms[roomId].state[type][stateKey];
|
||||||
@@ -268,12 +272,14 @@ var init = function(exports){
|
|||||||
// tracking current display name / avatar per-message
|
// tracking current display name / avatar per-message
|
||||||
// pagination
|
// pagination
|
||||||
// re-sending (including persisting pending messages to be sent)
|
// re-sending (including persisting pending messages to be sent)
|
||||||
// - Need a nice way to callback the app for arbitrary events like displayname changes
|
// - Need a nice way to callback the app for arbitrary events like
|
||||||
|
// displayname changes
|
||||||
// due to ambiguity (or should this be on a chat-specific layer)?
|
// due to ambiguity (or should this be on a chat-specific layer)?
|
||||||
// reconnect after connectivity outages
|
// reconnect after connectivity outages
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper method for retrieving the name of a room suitable for display in the UI
|
* Helper method for retrieving the name of a room suitable for display
|
||||||
|
* in the UI
|
||||||
* TODO: in future, this should be being generated serverside.
|
* TODO: in future, this should be being generated serverside.
|
||||||
* @param {String} roomId ID of room whose name is to be resolved
|
* @param {String} roomId ID of room whose name is to be resolved
|
||||||
* @return {String} human-readable label for room.
|
* @return {String} human-readable label for room.
|
||||||
@@ -284,7 +290,8 @@ var init = function(exports){
|
|||||||
return roomId;
|
return roomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for an alias, if any. for now, assume first alias is the official one.
|
// check for an alias, if any. for now, assume first alias is the
|
||||||
|
// official one.
|
||||||
var alias;
|
var alias;
|
||||||
var mRoomAliases = this.store.getStateEvents(roomId, 'm.room.aliases')[0];
|
var mRoomAliases = this.store.getStateEvents(roomId, 'm.room.aliases')[0];
|
||||||
if (mRoomAliases) {
|
if (mRoomAliases) {
|
||||||
@@ -309,26 +316,41 @@ var init = function(exports){
|
|||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
else if (members.length == 1) {
|
else if (members.length == 1) {
|
||||||
return members[0].event.content.displayname || members[0].event.user_id;
|
return (
|
||||||
|
members[0].event.content.displayname ||
|
||||||
|
members[0].event.user_id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if (members.length == 2) {
|
else if (members.length == 2) {
|
||||||
return (members[0].event.content.displayname || members[0].event.user_id) + " and " +
|
return (
|
||||||
(members[1].event.content.displayname || members[1].event.user_id);
|
(members[0].event.content.displayname ||
|
||||||
|
members[0].event.user_id) +
|
||||||
|
" and " +
|
||||||
|
(members[1].event.content.displayname ||
|
||||||
|
members[1].event.user_id)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (members[0].event.content.displayname || members[0].event.user_id) + " and " +
|
return (
|
||||||
(members.length - 1) + " others";
|
(members[0].event.content.displayname ||
|
||||||
|
members[0].event.user_id) +
|
||||||
|
" and " +
|
||||||
|
(members.length - 1) + " others"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper method for retrieving the name of a user suitable for display in the UI
|
* Helper method for retrieving the name of a user suitable for display
|
||||||
* in the context of a room - i.e. disambiguating from any other users in the room.
|
* in the UI in the context of a room - i.e. disambiguating from any
|
||||||
|
* other users in the room.
|
||||||
* XXX: This could perhaps also be generated serverside, perhaps by just passing
|
* XXX: This could perhaps also be generated serverside, perhaps by just passing
|
||||||
* a 'disambiguate' flag down on membership entries which have ambiguous displaynames?
|
* a 'disambiguate' flag down on membership entries which have ambiguous
|
||||||
|
* displaynames?
|
||||||
* @param {String} userId ID of the user whose name is to be resolved
|
* @param {String} userId ID of the user whose name is to be resolved
|
||||||
* @param {String} roomId ID of room to be used as the context for resolving the name
|
* @param {String} roomId ID of room to be used as the context for
|
||||||
|
* resolving the name.
|
||||||
* @return {String} human-readable name of the user.
|
* @return {String} human-readable name of the user.
|
||||||
*/
|
*/
|
||||||
getFriendlyDisplayName: function(userId, roomId) {
|
getFriendlyDisplayName: function(userId, roomId) {
|
||||||
@@ -361,7 +383,8 @@ var init = function(exports){
|
|||||||
* High level helper method to call initialSync, emit the resulting events,
|
* High level helper method to call initialSync, emit the resulting events,
|
||||||
* and then start polling the eventStream for new events.
|
* and then start polling the eventStream for new events.
|
||||||
* @param {function} callback Callback invoked whenever new event are available
|
* @param {function} callback Callback invoked whenever new event are available
|
||||||
* @param {Number} historyLen amount of historical timeline events to emit during from the initial sync
|
* @param {Number} historyLen amount of historical timeline events to
|
||||||
|
* emit during from the initial sync.
|
||||||
*/
|
*/
|
||||||
startClient: function(callback, historyLen) {
|
startClient: function(callback, historyLen) {
|
||||||
historyLen = historyLen || 12;
|
historyLen = historyLen || 12;
|
||||||
@@ -371,7 +394,10 @@ var init = function(exports){
|
|||||||
this.initialSync(historyLen, function(err, data) {
|
this.initialSync(historyLen, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (this.config && this.config.debug) {
|
if (this.config && this.config.debug) {
|
||||||
console.error("startClient error on initialSync: %s", JSON.stringify(err));
|
console.error(
|
||||||
|
"startClient error on initialSync: %s",
|
||||||
|
JSON.stringify(err)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
callback(err);
|
callback(err);
|
||||||
} else {
|
} else {
|
||||||
@@ -385,7 +411,9 @@ var init = function(exports){
|
|||||||
events.push(new MatrixEvent(data.rooms[i].state[j]));
|
events.push(new MatrixEvent(data.rooms[i].state[j]));
|
||||||
}
|
}
|
||||||
for (j = 0; j < data.rooms[i].messages.chunk.length; j++) {
|
for (j = 0; j < data.rooms[i].messages.chunk.length; j++) {
|
||||||
events.push(new MatrixEvent(data.rooms[i].messages.chunk[j]));
|
events.push(
|
||||||
|
new MatrixEvent(data.rooms[i].messages.chunk[j])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback(undefined, events, false);
|
callback(undefined, events, false);
|
||||||
@@ -407,7 +435,10 @@ var init = function(exports){
|
|||||||
this.eventStream(this.fromToken, 30000, function(err, data) {
|
this.eventStream(this.fromToken, 30000, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (this.config && this.config.debug) {
|
if (this.config && this.config.debug) {
|
||||||
console.error("error polling for events via eventStream: %s", JSON.stringify(err));
|
console.error(
|
||||||
|
"error polling for events via eventStream: %s",
|
||||||
|
JSON.stringify(err)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
callback(err);
|
callback(err);
|
||||||
// retry every few seconds
|
// retry every few seconds
|
||||||
@@ -427,7 +458,8 @@ var init = function(exports){
|
|||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* High level helper method to stop the client from polling and allow a clean shutdown
|
* High level helper method to stop the client from polling and allow a
|
||||||
|
* clean shutdown.
|
||||||
*/
|
*/
|
||||||
stopClient: function() {
|
stopClient: function() {
|
||||||
this.clientRunning = false;
|
this.clientRunning = false;
|
||||||
@@ -954,8 +986,8 @@ var init = function(exports){
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the content repository url with query parameters.
|
* Get the content repository url with query parameters.
|
||||||
* @returns An object with a 'base', 'path' and 'params' for base URL,
|
* @return {Object} An object with a 'base', 'path' and 'params' for
|
||||||
* path and query parameters respectively.
|
* base URL, path and query parameters respectively.
|
||||||
*/
|
*/
|
||||||
getContentUri: function() {
|
getContentUri: function() {
|
||||||
var params = {
|
var params = {
|
||||||
|
|||||||
Reference in New Issue
Block a user