Merge pull request #2938 from matrix-org/jryans/lint-timeline-panel
Fix lint errors in TimelinePanel
This commit is contained in:
commit
187193f689
2 changed files with 27 additions and 18 deletions
|
@ -10,7 +10,6 @@ src/components/structures/RoomStatusBar.js
|
||||||
src/components/structures/RoomView.js
|
src/components/structures/RoomView.js
|
||||||
src/components/structures/ScrollPanel.js
|
src/components/structures/ScrollPanel.js
|
||||||
src/components/structures/SearchBox.js
|
src/components/structures/SearchBox.js
|
||||||
src/components/structures/TimelinePanel.js
|
|
||||||
src/components/structures/UploadBar.js
|
src/components/structures/UploadBar.js
|
||||||
src/components/views/avatars/BaseAvatar.js
|
src/components/views/avatars/BaseAvatar.js
|
||||||
src/components/views/avatars/MemberAvatar.js
|
src/components/views/avatars/MemberAvatar.js
|
||||||
|
|
|
@ -44,11 +44,10 @@ const READ_RECEIPT_INTERVAL_MS = 500;
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
|
|
||||||
|
let debuglog = function() {};
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
// using bind means that we get to keep useful line numbers in the console
|
// using bind means that we get to keep useful line numbers in the console
|
||||||
var debuglog = console.log.bind(console);
|
debuglog = console.log.bind(console);
|
||||||
} else {
|
|
||||||
var debuglog = function() {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -56,7 +55,7 @@ if (DEBUG) {
|
||||||
*
|
*
|
||||||
* Also responsible for handling and sending read receipts.
|
* Also responsible for handling and sending read receipts.
|
||||||
*/
|
*/
|
||||||
var TimelinePanel = React.createClass({
|
const TimelinePanel = React.createClass({
|
||||||
displayName: 'TimelinePanel',
|
displayName: 'TimelinePanel',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -445,6 +444,7 @@ var TimelinePanel = React.createClass({
|
||||||
|
|
||||||
const updatedState = {events: events};
|
const updatedState = {events: events};
|
||||||
|
|
||||||
|
let callRMUpdated;
|
||||||
if (this.props.manageReadMarkers) {
|
if (this.props.manageReadMarkers) {
|
||||||
// when a new event arrives when the user is not watching the
|
// when a new event arrives when the user is not watching the
|
||||||
// window, but the window is in its auto-scroll mode, make sure the
|
// window, but the window is in its auto-scroll mode, make sure the
|
||||||
|
@ -456,7 +456,7 @@ var TimelinePanel = React.createClass({
|
||||||
//
|
//
|
||||||
const myUserId = MatrixClientPeg.get().credentials.userId;
|
const myUserId = MatrixClientPeg.get().credentials.userId;
|
||||||
const sender = ev.sender ? ev.sender.userId : null;
|
const sender = ev.sender ? ev.sender.userId : null;
|
||||||
var callRMUpdated = false;
|
callRMUpdated = false;
|
||||||
if (sender != myUserId && !UserActivity.sharedInstance().userActiveRecently()) {
|
if (sender != myUserId && !UserActivity.sharedInstance().userActiveRecently()) {
|
||||||
updatedState.readMarkerVisible = true;
|
updatedState.readMarkerVisible = true;
|
||||||
} else if (lastEv && this.getReadMarkerPosition() === 0) {
|
} else if (lastEv && this.getReadMarkerPosition() === 0) {
|
||||||
|
@ -566,7 +566,7 @@ var TimelinePanel = React.createClass({
|
||||||
UserActivity.sharedInstance().timeWhileActiveRecently(this._readMarkerActivityTimer);
|
UserActivity.sharedInstance().timeWhileActiveRecently(this._readMarkerActivityTimer);
|
||||||
try {
|
try {
|
||||||
await this._readMarkerActivityTimer.finished();
|
await this._readMarkerActivityTimer.finished();
|
||||||
} catch(e) { continue; /* aborted */ }
|
} catch (e) { continue; /* aborted */ }
|
||||||
// outside of try/catch to not swallow errors
|
// outside of try/catch to not swallow errors
|
||||||
this.updateReadMarker();
|
this.updateReadMarker();
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ var TimelinePanel = React.createClass({
|
||||||
UserActivity.sharedInstance().timeWhileActiveNow(this._readReceiptActivityTimer);
|
UserActivity.sharedInstance().timeWhileActiveNow(this._readReceiptActivityTimer);
|
||||||
try {
|
try {
|
||||||
await this._readReceiptActivityTimer.finished();
|
await this._readReceiptActivityTimer.finished();
|
||||||
} catch(e) { continue; /* aborted */ }
|
} catch (e) { continue; /* aborted */ }
|
||||||
// outside of try/catch to not swallow errors
|
// outside of try/catch to not swallow errors
|
||||||
this.sendReadReceipt();
|
this.sendReadReceipt();
|
||||||
}
|
}
|
||||||
|
@ -732,7 +732,8 @@ var TimelinePanel = React.createClass({
|
||||||
const events = this._timelineWindow.getEvents();
|
const events = this._timelineWindow.getEvents();
|
||||||
|
|
||||||
// first find where the current RM is
|
// first find where the current RM is
|
||||||
for (var i = 0; i < events.length; i++) {
|
let i;
|
||||||
|
for (i = 0; i < events.length; i++) {
|
||||||
if (events[i].getId() == this.state.readMarkerEventId) {
|
if (events[i].getId() == this.state.readMarkerEventId) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -744,7 +745,7 @@ var TimelinePanel = React.createClass({
|
||||||
// now think about advancing it
|
// now think about advancing it
|
||||||
const myUserId = MatrixClientPeg.get().credentials.userId;
|
const myUserId = MatrixClientPeg.get().credentials.userId;
|
||||||
for (i++; i < events.length; i++) {
|
for (i++; i < events.length; i++) {
|
||||||
var ev = events[i];
|
const ev = events[i];
|
||||||
if (!ev.sender || ev.sender.userId != myUserId) {
|
if (!ev.sender || ev.sender.userId != myUserId) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -752,7 +753,7 @@ var TimelinePanel = React.createClass({
|
||||||
// i is now the first unread message which we didn't send ourselves.
|
// i is now the first unread message which we didn't send ourselves.
|
||||||
i--;
|
i--;
|
||||||
|
|
||||||
var ev = events[i];
|
const ev = events[i];
|
||||||
this._setReadMarker(ev.getId(), ev.getTs());
|
this._setReadMarker(ev.getId(), ev.getTs());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -882,7 +883,7 @@ var TimelinePanel = React.createClass({
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* called by the parent component when PageUp/Down/etc is pressed.
|
* called by the parent component when PageUp/Down/etc is pressed.
|
||||||
*
|
*
|
||||||
* We pass it down to the scroll panel.
|
* We pass it down to the scroll panel.
|
||||||
|
@ -975,11 +976,10 @@ var TimelinePanel = React.createClass({
|
||||||
};
|
};
|
||||||
|
|
||||||
const onError = (error) => {
|
const onError = (error) => {
|
||||||
this.setState({timelineLoading: false});
|
this.setState({ timelineLoading: false });
|
||||||
console.error(
|
console.error(
|
||||||
`Error loading timeline panel at ${eventId}: ${error}`,
|
`Error loading timeline panel at ${eventId}: ${error}`,
|
||||||
);
|
);
|
||||||
const msg = error.message ? error.message : JSON.stringify(error);
|
|
||||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
|
||||||
let onFinished;
|
let onFinished;
|
||||||
|
@ -997,9 +997,18 @@ var TimelinePanel = React.createClass({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const message = (error.errcode == 'M_FORBIDDEN')
|
let message;
|
||||||
? _t("Tried to load a specific point in this room's timeline, but you do not have permission to view the message in question.")
|
if (error.errcode == 'M_FORBIDDEN') {
|
||||||
: _t("Tried to load a specific point in this room's timeline, but was unable to find it.");
|
message = _t(
|
||||||
|
"Tried to load a specific point in this room's timeline, but you " +
|
||||||
|
"do not have permission to view the message in question.",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
message = _t(
|
||||||
|
"Tried to load a specific point in this room's timeline, but was " +
|
||||||
|
"unable to find it.",
|
||||||
|
);
|
||||||
|
}
|
||||||
Modal.createTrackedDialog('Failed to load timeline position', '', ErrorDialog, {
|
Modal.createTrackedDialog('Failed to load timeline position', '', ErrorDialog, {
|
||||||
title: _t("Failed to load timeline position"),
|
title: _t("Failed to load timeline position"),
|
||||||
description: message,
|
description: message,
|
||||||
|
@ -1104,12 +1113,13 @@ var TimelinePanel = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the id of the event corresponding to our user's latest read-receipt.
|
* Get the id of the event corresponding to our user's latest read-receipt.
|
||||||
*
|
*
|
||||||
* @param {Boolean} ignoreSynthesized If true, return only receipts that
|
* @param {Boolean} ignoreSynthesized If true, return only receipts that
|
||||||
* have been sent by the server, not
|
* have been sent by the server, not
|
||||||
* implicit ones generated by the JS
|
* implicit ones generated by the JS
|
||||||
* SDK.
|
* SDK.
|
||||||
|
* @return {String} the event ID
|
||||||
*/
|
*/
|
||||||
_getCurrentReadReceipt: function(ignoreSynthesized) {
|
_getCurrentReadReceipt: function(ignoreSynthesized) {
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
|
|
Loading…
Reference in a new issue