edited for code style consistency

This commit is contained in:
or-else
2022-11-19 17:14:43 -08:00
parent 3653453897
commit 72ec3b51a0
19 changed files with 216 additions and 337 deletions
+4 -4
View File
@@ -138,10 +138,10 @@ export function imageCrop(mime, objURL, left, top, width, height, scale) {
return new Promise((resolve, reject) => {
const img = new Image();
img.crossOrigin = 'Anonymous';
img.onerror = (err) => {
img.onerror = _ => {
reject(new Error("Image format unrecognized"));
};
img.onload = () => {
img.onload = _ => {
// Once the image is loaded, the URL is no longer needed.
URL.revokeObjectURL(img.src);
@@ -175,7 +175,7 @@ export function fileToBase64(file) {
reader.onerror = (evt) => {
reject(reader.error);
};
reader.onload = () => {
reader.onload = _ => {
resolve({mime: file.type, bits: reader.result.split(',')[1], name: file.name});
};
reader.readAsDataURL(file);
@@ -189,7 +189,7 @@ export function blobToBase64(blob) {
reader.onerror = _ => {
reject(reader.error);
};
reader.onload = () => {
reader.onload = _ => {
resolve({mime: blob.type, bits: reader.result.split(',')[1]});
};
reader.readAsDataURL(blob);
+1 -1
View File
@@ -76,7 +76,7 @@ class AccSecurityView extends React.Component {
this.props.onShowAlert(
formatMessage(messages.delete_account), // title
formatMessage(messages.delete_account_warning), // content
(() => { this.props.onDeleteAccount(); }), // onConfirm
(_ => this.props.onDeleteAccount()), // onConfirm
null, // use default text "OK"
true, // Show Reject button
null // use default text "Cancel"
+4 -5
View File
@@ -410,11 +410,10 @@ class InfoView extends React.Component {
}
const isMe = this.props.tinode.isMe(params.topicName);
const menuItems = [
{title: formatMessage(messages.edit_permissions), handler: () => {
this.handleLaunchPermissionsEditor(isMe ? 'want' : 'user', params.topicName);
}}
];
const menuItems = [{
title: formatMessage(messages.edit_permissions),
handler: _ => this.handleLaunchPermissionsEditor(isMe ? 'want' : 'user', params.topicName)
}];
if (!isMe) {
menuItems.push('member_delete');
}
+10 -13
View File
@@ -400,7 +400,7 @@ class MessagesView extends React.Component {
const setQuery = newTopic ? this.props.newTopicParams : undefined;
topic.subscribe(getQuery.build(), setQuery)
.then((ctrl) => {
.then(ctrl => {
if (ctrl.code == 303) {
// Redirect to another topic requested.
HashNavigation.navigateTo(HashNavigation.setUrlTopic('', ctrl.params.topic));
@@ -430,7 +430,7 @@ class MessagesView extends React.Component {
topic.delMessagesList(calls, true);
}
})
.catch((err) => {
.catch(err => {
console.error("Failed subscription to", this.state.topic, err);
this.props.onError(err.message, 'err');
const blankState = MessagesView.getDerivedStateFromProps({}, {});
@@ -447,8 +447,8 @@ class MessagesView extends React.Component {
const oldTopic = this.props.tinode.getTopic(oldTopicName);
if (oldTopic && oldTopic.isSubscribed()) {
oldTopic.leave(false)
.catch(() => { /* do nothing here */ })
.finally(() => {
.catch(_ => { /* do nothing here */ })
.finally(_ => {
// We don't care if the request succeeded or failed.
// The topic is dead regardless.
this.setState({fetchingMessages: false});
@@ -487,10 +487,10 @@ class MessagesView extends React.Component {
if (event.target.scrollTop <= 0) {
const topic = this.props.tinode.getTopic(this.state.topic);
if (topic && topic.isSubscribed() && topic.msgHasMoreMessages()) {
this.setState({fetchingMessages: true}, () => {
this.setState({fetchingMessages: true}, _ => {
topic.getMessagesPage(MESSAGES_PAGE)
.catch((err) => this.props.onError(err.message, 'err'))
.finally(() => this.setState({fetchingMessages: false}));
.catch(err => this.props.onError(err.message, 'err'))
.finally(_ => this.setState({fetchingMessages: false}));
});
}
}
@@ -656,9 +656,7 @@ class MessagesView extends React.Component {
switch (info.what) {
case 'kp': {
clearTimeout(this.keyPressTimer);
this.keyPressTimer = setTimeout(() => {
this.setState({typingIndicator: false});
}, KEYPRESS_DELAY + 1000);
this.keyPressTimer = setTimeout(_ => this.setState({typingIndicator: false}), KEYPRESS_DELAY + 1000);
if (!this.state.typingIndicator) {
this.setState({typingIndicator: true});
}
@@ -893,9 +891,8 @@ class MessagesView extends React.Component {
}
// Pass data and the uploader to the TinodeWeb.
this.sendMessage(msg, uploadCompletionPromise, uploader);
}).catch((err) => {
this.props.onError(err, 'err');
});
})
.catch(err => this.props.onError(err, 'err'));
return;
}
+1 -3
View File
@@ -35,9 +35,7 @@ export default class PasswordResetView extends React.PureComponent {
} else {
const email = this.state.email.trim();
this.setState({email: email});
this.props.onRequest('email', email).then(() => {
this.setState({sent: true});
});
this.props.onRequest('email', email).then(_ => this.setState({sent: true}));
}
}
+74 -105
View File
@@ -303,7 +303,7 @@ class TinodeWeb extends React.Component {
if (this.state.desktopAlerts) {
this.tinode.setDeviceToken(this.state.firebaseToken);
}
}).catch(() => {
}).catch(_ => {
// do nothing: handled earlier.
// catch needed to pervent unnecessary logging of error.
});
@@ -322,7 +322,7 @@ class TinodeWeb extends React.Component {
// When reading from storage, date is returned as string.
token.expires = new Date(token.expires);
this.tinode.setAuthToken(token);
this.tinode.connect().catch((err) => {
this.tinode.connect().catch(err => {
// Socket error
this.handleError(err.message, 'err');
});
@@ -400,7 +400,7 @@ class TinodeWeb extends React.Component {
// (a) for channels always,
// (b) pushes when the app is in foreground but has no focus.
firebaseOnMessage(this.fcm, (payload) => { this.handlePushMessage(payload); });
}).catch((err) => {
}).catch(err => {
// SW registration or FCM has failed :(
onError(err);
throw err;
@@ -454,9 +454,9 @@ class TinodeWeb extends React.Component {
// Check if a newer version of TinodeWeb app is available at the server.
checkForAppUpdate(reg) {
reg.onupdatefound = () => {
reg.onupdatefound = _ => {
const installingWorker = reg.installing;
installingWorker.onstatechange = () => {
installingWorker.onstatechange = _ => {
if (installingWorker.state == 'installed' && navigator.serviceWorker.controller) {
const msg = <>
<FormattedMessage id="update_available"
@@ -570,7 +570,7 @@ class TinodeWeb extends React.Component {
if (this.tinode.isConnected()) {
this.doLogin(login, password, null, {meth: this.state.credMethod, resp: this.state.credCode});
} else {
this.tinode.connect().catch((err) => {
this.tinode.connect().catch(err => {
// Socket error
this.setState({loginDisabled: false, autoLogin: false, loadSpinnerVisible: false});
this.handleError(err.message, 'err');
@@ -581,12 +581,12 @@ class TinodeWeb extends React.Component {
// Enable or disable saving the password and IndexedDB.
handlePersistenceChange(persist) {
if (persist) {
this.tinode.initStorage().then(() => {
this.tinode.initStorage().then(_ => {
LocalStorageUtil.setObject('keep-logged-in', true);
this.setState({persist: true});
});
} else {
this.tinode.clearStorage().then(() => {
this.tinode.clearStorage().then(_ => {
LocalStorageUtil.setObject('keep-logged-in', false);
this.setState({persist: false});
});
@@ -625,7 +625,7 @@ class TinodeWeb extends React.Component {
prom.then(_ => {
// Reconnected: clear error
this.handleError();
}).catch((err) => {
}).catch(err => {
this.handleError(err.message, 'err');
});
return;
@@ -701,7 +701,7 @@ class TinodeWeb extends React.Component {
loginPromise = connectionPromise.then(_ => this.tinode.loginToken(token, cred));
}
loginPromise.then((ctrl) => {
loginPromise.then(ctrl => {
if (ctrl.code >= 300 && ctrl.text === 'validate credentials') {
this.setState({loadSpinnerVisible: false});
if (cred) {
@@ -711,7 +711,7 @@ class TinodeWeb extends React.Component {
} else {
this.handleLoginSuccessful();
}
}).catch((err) => {
}).catch(err => {
// Connection or login failed, report error.
this.setState({
loginDisabled: false,
@@ -768,12 +768,12 @@ class TinodeWeb extends React.Component {
withTags().
withCred().
build()
).catch((err) => {
).catch(err => {
this.tinode.disconnect();
localStorage.removeItem('auth-token');
this.handleError(err.message, 'err');
HashNavigation.navigateTo('');
}).finally(() => {
}).finally(_ => {
this.setState({loadSpinnerVisible: false});
});
let urlHash = HashNavigation.setUrlSidePanel(window.location.hash, 'contacts');
@@ -934,7 +934,7 @@ class TinodeWeb extends React.Component {
if (fnd.isSubscribed()) {
this.tnFndSubsUpdated();
} else {
fnd.subscribe(fnd.startMetaQuery().withSub().build()).catch((err) => {
fnd.subscribe(fnd.startMetaQuery().withSub().build()).catch(err => {
this.handleError(err.message, 'err');
});
}
@@ -957,11 +957,9 @@ class TinodeWeb extends React.Component {
*/
handleSearchContacts(query) {
const fnd = this.tinode.getFndTopic();
fnd.setMeta({desc: {public: query}}).then((ctrl) => {
return fnd.getMeta(fnd.startMetaQuery().withSub().build());
}).catch((err) => {
this.handleError(err.message, 'err');
});
fnd.setMeta({desc: {public: query}})
.then(_ => fnd.getMeta(fnd.startMetaQuery().withSub().build()))
.catch(err => this.handleError(err.message, 'err'));
}
// User clicked on a topic in the side panel or deleted a topic.
@@ -1043,7 +1041,7 @@ class TinodeWeb extends React.Component {
// Topic is not subscribed yet. Subscribe.
const subscribePromise =
topic.subscribe()
.then(() => {
.then(_ => {
// If there are unsent messages (except video call messages),
// try sending them now. Unsent video call messages will be dropped.
let calls = [];
@@ -1069,15 +1067,13 @@ class TinodeWeb extends React.Component {
// TODO: check if return is required.
return topic.publishDraft(msg, Promise.all(completion))
.then((ctrl) => {
.then(ctrl => {
if (topic.isArchived()) {
topic.archive(false);
}
return ctrl;
})
.catch((err) => {
this.handleError(err.message, 'err');
});
.catch(err => this.handleError(err.message, 'err'));
}
handleNewChatInvitation(topicName, action) {
@@ -1091,9 +1087,7 @@ class TinodeWeb extends React.Component {
if (topic.isP2PType()) {
// For P2P topics change 'given' permission of the peer too.
// In p2p topics the other user has the same name as the topic.
response = response.then((ctrl) => {
topic.setMeta({sub: {user: topicName, mode: mode}});
});
response = response.then(_ => topic.setMeta({sub: {user: topicName, mode: mode}}));
}
break;
case 'delete':
@@ -1104,18 +1098,14 @@ class TinodeWeb extends React.Component {
// Ban the topic making futher invites impossible.
// Just self-ban.
const am = topic.getAccessMode().updateWant('-JP').getWant();
response = topic.setMeta({sub: {mode: am}}).then((ctrl) => {
return this.handleTopicSelected(null);
});
response = topic.setMeta({sub: {mode: am}}).then(_ => this.handleTopicSelected(null));
break;
default:
console.warn("Unknown invitation action", '"' + action + '""');
}
if (response != null) {
response.catch((err) => {
this.handleError(err.message, 'err');
});
response.catch(err => this.handleError(err.message, 'err'));
}
}
@@ -1156,7 +1146,7 @@ class TinodeWeb extends React.Component {
const me = this.tinode.getMeTopic();
const am = me.getAccessMode().updateWant(on ? '-P' : '+P').getWant();
me.setMeta({sub: {mode: am}}).catch((err) => {
me.setMeta({sub: {mode: am}}).catch(err => {
// Request failed, keep existing state.
this.setState({incognitoMode: !on});
this.handleError(err.message, 'err');
@@ -1165,9 +1155,7 @@ class TinodeWeb extends React.Component {
handleUpdateAccountTagsRequest(tags) {
this.tinode.getMeTopic().setMeta({tags: tags})
.catch((err) => {
this.handleError(err.message, 'err');
});
.catch(err => this.handleError(err.message, 'err'));
}
// User chose Settings menu item.
@@ -1235,9 +1223,9 @@ class TinodeWeb extends React.Component {
}
}
} else if (this.state.firebaseToken && this.fcm) {
firebaseDelToken(this.fcm).catch((err) => {
firebaseDelToken(this.fcm).catch(err => {
console.error("Unable to delete token.", err);
}).finally(() => {
}).finally(_ => {
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
localStorage.removeItem('firebase-token');
this.setState({desktopAlerts: false, firebaseToken: null});
@@ -1259,16 +1247,14 @@ class TinodeWeb extends React.Component {
handleCredAdd(method, value) {
const me = this.tinode.getMeTopic();
me.setMeta({cred: {meth: method, val: value}}).catch((err) => {
this.handleError(err.message, 'err');
});
me.setMeta({cred: {meth: method, val: value}})
.catch(err => this.handleError(err.message, 'err'));
}
handleCredDelete(method, value) {
const me = this.tinode.getMeTopic();
me.delCredential(method, value).catch((err) => {
this.handleError(err.message, 'err');
});
me.delCredential(method, value)
.catch(err => this.handleError(err.message, 'err'));
}
handleCredConfirm(method, response) {
@@ -1332,7 +1318,7 @@ class TinodeWeb extends React.Component {
}
}
params._topicName = topicName;
this.setState({newTopicParams: params}, () => {this.handleTopicSelected(topicName)});
this.setState({newTopicParams: params}, _ => {this.handleTopicSelected(topicName)});
}
// New topic was created, here is the new topic name.
@@ -1377,18 +1363,15 @@ class TinodeWeb extends React.Component {
if (defacs) {
params.defacs = defacs;
}
topic.setMeta({desc: params, attachments: attachments}).catch((err) => {
this.handleError(err.message, 'err');
});
topic.setMeta({desc: params, attachments: attachments})
.catch(err => this.handleError(err.message, 'err'));
}
}
handleUnarchive(topicName) {
const topic = this.tinode.getTopic(topicName);
if (topic) {
topic.archive(false).catch((err) => {
this.handleError(err.message, 'err');
});
topic.archive(false).catch(err => this.handleError(err.message, 'err'));
}
}
@@ -1396,9 +1379,8 @@ class TinodeWeb extends React.Component {
this.handleError();
if (password) {
this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password).catch((err) => {
this.handleError(err.message, 'err');
});
this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password)
.catch(err => this.handleError(err.message, 'err'));
}
}
@@ -1413,18 +1395,16 @@ class TinodeWeb extends React.Component {
am.updateWant(mode);
mode = am.getWant();
}
topic.setMeta({sub: {user: uid, mode: mode}}).catch((err) => {
this.handleError(err.message, 'err');
});
topic.setMeta({sub: {user: uid, mode: mode}})
.catch(err => this.handleError(err.message, 'err'));
}
}
handleTagsUpdateRequest(topicName, tags) {
const topic = this.tinode.getTopic(topicName);
if (topic) {
topic.setMeta({tags: tags}).catch((err) => {
this.handleError(err.message, 'err');
});
topic.setMeta({tags: tags})
.catch(err => this.handleError(err.message, 'err'));
}
}
@@ -1451,9 +1431,9 @@ class TinodeWeb extends React.Component {
}
this.setState(this.getBlankState());
cleared.then(() => {
cleared.then(_ => {
this.tinode = TinodeWeb.tnSetup(this.state.serverAddress, isSecureConnection(),
this.state.transport, this.props.intl.locale, LocalStorageUtil.getObject('keep-logged-in'), () => {
this.state.transport, this.props.intl.locale, LocalStorageUtil.getObject('keep-logged-in'), _ => {
this.tinode.onConnect = this.handleConnected;
this.tinode.onDisconnect = this.handleDisconnect;
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
@@ -1477,10 +1457,10 @@ class TinodeWeb extends React.Component {
}
// Request to hard-delete topic.
topic.delTopic(true).then((ctrl) => {
topic.delTopic(true).then(_ => {
// Hide MessagesView and InfoView panels.
HashNavigation.navigateTo(HashNavigation.setUrlTopic(window.location.hash, ''));
}).catch((err) => {
}).catch(err => {
this.handleError(err.message, 'err');
});
}
@@ -1492,9 +1472,8 @@ class TinodeWeb extends React.Component {
}
// Request hard-delete all messages.
topic.delMessagesAll(true).catch((err) => {
this.handleError(err.message, 'err');
});
topic.delMessagesAll(true)
.catch(err => this.handleError(err.message, 'err'));
}
handleLeaveUnsubRequest(topicName) {
@@ -1503,10 +1482,10 @@ class TinodeWeb extends React.Component {
return;
}
topic.leave(true).then((ctrl) => {
topic.leave(true).then(_ => {
// Hide MessagesView and InfoView panels.
HashNavigation.navigateTo(HashNavigation.setUrlTopic(window.location.hash, ''));
}).catch((err) => {
}).catch(err => {
this.handleError(err.message, 'err');
});
}
@@ -1517,12 +1496,12 @@ class TinodeWeb extends React.Component {
return;
}
topic.updateMode(null, '-JP').then(_ => {
// Hide MessagesView and InfoView panels.
HashNavigation.navigateTo(HashNavigation.setUrlTopic(window.location.hash, ''));
}).catch((err) => {
this.handleError(err.message, 'err');
});
topic.updateMode(null, '-JP')
.then(_ => {
// Hide MessagesView and InfoView panels.
HashNavigation.navigateTo(HashNavigation.setUrlTopic(window.location.hash, ''));
})
.catch(err => this.handleError(err.message, 'err'));
}
handleReportTopic(topicName) {
@@ -1535,12 +1514,12 @@ class TinodeWeb extends React.Component {
this.tinode.report('report', topicName);
// Remove J and P permissions.
topic.updateMode(null, '-JP').then((ctrl) => {
topic.updateMode(null, '-JP')
.then(_ => {
// Hide MessagesView and InfoView panels.
HashNavigation.navigateTo(HashNavigation.setUrlTopic(window.location.hash, ''));
}).catch((err) => {
this.handleError(err.message, 'err');
});
})
.catch(err => this.handleError(err.message, 'err'));
}
handleShowContextMenu(params, menuItems) {
@@ -1637,7 +1616,7 @@ class TinodeWeb extends React.Component {
handleContextMenuAction(action, promise, params) {
if (action == 'topic_archive') {
if (promise && params.topicName && params.topicName == this.state.topicSelected) {
promise.then(() => {
promise.then(_ => {
this.handleTopicSelected(null);
});
}
@@ -1677,17 +1656,15 @@ class TinodeWeb extends React.Component {
if (added && added.length > 0) {
added.map((uid) => {
topic.invite(uid, null).catch((err) => {
this.handleError(err.message, 'err');
});
topic.invite(uid, null)
.catch(err => this.handleError(err.message, 'err'));
});
}
if (removed && removed.length > 0) {
removed.map((uid) => {
topic.delSubscription(uid).catch((err) => {
this.handleError(err.message, 'err');
});
topic.delSubscription(uid)
.catch(err => this.handleError(err.message, 'err'));
});
}
}
@@ -1696,9 +1673,7 @@ class TinodeWeb extends React.Component {
if (this.tinode.isAuthenticated()) {
// Adding new email or phone number in account setting.
this.tinode.getMeTopic().setMeta({cred: {meth: cred, resp: code}})
.catch((err) => {
this.handleError(err.message, 'err');
});
.catch(err => this.handleError(err.message, 'err'));
} else {
// Credential validation on signup.
this.setState({credMethod: cred, credCode: code, credToken: token});
@@ -1709,10 +1684,8 @@ class TinodeWeb extends React.Component {
handlePasswordResetRequest(method, value) {
// If already connected, connnect() will return a resolved promise.
return this.tinode.connect()
.then(() => {
return this.tinode.requestResetAuthSecret('basic', method, value);
})
.catch((err) => {
.then(_ => this.tinode.requestResetAuthSecret('basic', method, value))
.catch(err => {
// Socket error
this.handleError(err.message, 'err');
});
@@ -1724,13 +1697,9 @@ class TinodeWeb extends React.Component {
this.handleError(this.props.intl.formatMessage(messages.invalid_security_token), 'err');
} else {
this.tinode.connect()
.then(() => {
return this.tinode.updateAccountBasic(null, null, newPassword, {token: token});
})
.then(() => {
HashNavigation.navigateTo('');
})
.catch((err) => {
.then(_ => this.tinode.updateAccountBasic(null, null, newPassword, {token: token}))
.then(_ => HashNavigation.navigateTo(''))
.catch(err => {
// Socket error
this.handleError(err.message, 'err');
});
@@ -1749,7 +1718,7 @@ class TinodeWeb extends React.Component {
case CALL_STATE_OUTGOING_INITATED:
let head = { webrtc: CALL_HEAD_STARTED };
this.handleSendMessage(Drafty.videoCall(), undefined, undefined, head)
.then((ctrl) => {
.then(ctrl => {
if (ctrl.code < 200 || ctrl.code >= 300 || !ctrl.params || !ctrl.params.seq) {
this.handleCallClose();
return;
@@ -1836,7 +1805,7 @@ class TinodeWeb extends React.Component {
// We need to switch and subscribe to callTopic first.
this.setState({
callShouldStart: true,
}, () => this.handleTopicSelected(this.state.callTopic));
}, _ => this.handleTopicSelected(this.state.callTopic));
}
}
@@ -1955,9 +1924,9 @@ class TinodeWeb extends React.Component {
visible={this.state.alertVisible}
title={this.state.alertParams.title}
content={this.state.alertParams.content}
onReject={this.state.alertParams.onReject ? (() => { this.setState({alertVisible: false}); }) : null}
onReject={this.state.alertParams.onReject ? (_ => this.setState({alertVisible: false})) : null}
reject={this.state.alertParams.reject}
onConfirm={() => { this.setState({alertVisible: false}); this.state.alertParams.onConfirm(); }}
onConfirm={_ => {this.setState({alertVisible: false}); this.state.alertParams.onConfirm();}}
confirm={this.state.alertParams.confirm}
/>
<SidepanelView
+5 -9
View File
@@ -27,15 +27,11 @@ export default class Attachment extends React.Component {
const downloader = this.props.tinode.getLargeFileHelper();
this.setState({downloader: downloader});
downloader.download(url, filename, mimetype,
(loaded) => {
this.setState({progress: loaded / this.props.size});
},
(err) => {
this.props.onError(err, 'err');
}
).then(() => {
this.setState({downloader: null, progress: 0});
}).catch((err) => {
loaded => this.setState({progress: loaded / this.props.size}),
err => this.props.onError(err, 'err')
)
.then(_ => this.setState({downloader: null, progress: 0}))
.catch(err => {
if (err) {
this.props.onError("Error downloading file: " + err.message, 'err');
}
+1 -1
View File
@@ -118,7 +118,7 @@ export default class AudioPlayer extends React.PureComponent {
this.canvasContext.lineWidth = LINE_WIDTH;
const drawFrame = () => {
const drawFrame = _ => {
if (!this.canvasRef.current || !this.audioPlayer) {
// The component is unmounted.
return;
+1 -1
View File
@@ -105,7 +105,7 @@ export default class AudioRecorder extends React.PureComponent {
let prevBarCount = 0;
let volume = 0.0;
let countPerBar = 0;
const drawFrame = () => {
const drawFrame = _ => {
if (!this.startedOn) {
return;
}
+2 -2
View File
@@ -231,7 +231,7 @@ class CallPanel extends React.PureComponent {
const desc = new RTCSessionDescription(info.payload);
this.state.pc.setRemoteDescription(desc)
.then(_ => {
this.setState({ callInitialSetupComplete: true }, () => this.drainRemoteIceCandidatesCache());
this.setState({ callInitialSetupComplete: true }, _ => this.drainRemoteIceCandidatesCache());
})
.catch(this.reportError);
}
@@ -357,7 +357,7 @@ class CallPanel extends React.PureComponent {
})
.then(_ => {
this.props.onSendAnswer(this.props.topic, this.props.seq, pc.localDescription.toJSON());
this.setState({ callInitialSetupComplete: true }, () => this.drainRemoteIceCandidatesCache());
this.setState({ callInitialSetupComplete: true }, _ => this.drainRemoteIceCandidatesCache());
})
.catch(this.handleGetUserMediaError);
}
+13 -17
View File
@@ -196,7 +196,7 @@ class ContextMenu extends React.Component {
'menu_item_forward': {
id: 'menu_item_forward',
title: formatMessage(messages.forward),
handler: () => {} /* the action is taken directly in tinode-web */
handler: _ => {} /* the action is taken directly in tinode-web */
},
'menu_item_edit': {
id: 'menu_item_edit',
@@ -227,12 +227,10 @@ class ContextMenu extends React.Component {
return props.onShowAlert(
formatMessage(messages.block), // title
formatMessage(messages.topic_block_warning), // content
(() => {
return this.topicPermissionSetter('-JP', params, errorHandler).then((ctrl) => {
this.props.onTopicRemoved(params.topicName);
return ctrl;
});
}),
(_ => this.topicPermissionSetter('-JP', params, errorHandler).then(ctrl => {
this.props.onTopicRemoved(params.topicName);
return ctrl;
})),
null, // "OK"
true, // Show Reject button
null // "Cancel"
@@ -246,13 +244,13 @@ class ContextMenu extends React.Component {
return props.onShowAlert(
formatMessage(messages.topic_delete), // title
formatMessage(messages.topic_delete_warning), // content
(() => {
(_ => {
const topic = this.props.tinode.getTopic(params.topicName);
if (!topic) {
console.warn("Topic not found: ", params.topicName);
return;
}
return topic.delTopic(true).catch((err) => {
return topic.delTopic(true).catch(err => {
if (errorHandler) {
errorHandler(err.message, 'err');
}
@@ -273,7 +271,7 @@ class ContextMenu extends React.Component {
console.warn("Topic not found: ", params.topicName);
return;
}
return topic.archive(true).catch((err) => {
return topic.archive(true).catch(err => {
if (errorHandler) {
errorHandler(err.message, 'err');
}
@@ -289,7 +287,7 @@ class ContextMenu extends React.Component {
console.warn("Topic not found: ", params.topicName);
return;
}
return topic.archive(false).catch((err) => {
return topic.archive(false).catch(err => {
if (errorHandler) {
errorHandler(err.message, 'err');
}
@@ -311,7 +309,7 @@ class ContextMenu extends React.Component {
console.warn("Topic or user not found: '" + params.topicName + "', '" + params.user + "'");
return;
}
return topic.delSubscription(params.user).catch((err) => {
return topic.delSubscription(params.user).catch(err => {
if (errorHandler) {
errorHandler(err.message, 'err');
}
@@ -406,7 +404,7 @@ class ContextMenu extends React.Component {
topic.delMessagesAll(hard) :
topic.delMessagesList([params.seq], hard);
return promise.catch((err) => {
return promise.catch(err => {
if (errorHandler) {
errorHandler(err.message, 'err');
}
@@ -421,7 +419,7 @@ class ContextMenu extends React.Component {
return;
}
const msg = topic.createMessage(params.content, false);
return topic.publishDraft(msg).catch((err) => {
return topic.publishDraft(msg).catch(err => {
if (errorHandler) {
errorHandler(err.message, 'err');
}
@@ -438,9 +436,7 @@ class ContextMenu extends React.Component {
let result = topic.updateMode(params.user, mode);
if (errorHandler) {
result = result.catch((err) => {
errorHandler(err.message, 'err');
});
result = result.catch(err => errorHandler(err.message, 'err'));
}
return result;
}
+1 -1
View File
@@ -50,7 +50,7 @@ export default class InPlaceEdit extends React.Component {
handleStartEditing() {
if (!this.props.readOnly) {
this.setState({active: true}, () => {
this.setState({active: true}, _ => {
if (this.selfRef.current) {
this.selfRef.current.focus();
}
+2 -2
View File
@@ -20,7 +20,7 @@ export default class LazyImage extends React.PureComponent {
this.props.whenDone
.promise
.then(data => this.setState({src: data.src, style: {...this.state.style, padding: 0}}))
.catch(() => this.setState({src: 'img/broken_image.png'}));
.catch(_ => this.setState({src: 'img/broken_image.png'}));
}
componentWillUnmount() {
@@ -33,7 +33,7 @@ export default class LazyImage extends React.PureComponent {
this.props.whenDone
.promise
.then(data => this.setState({src: data.src, style: {...this.state.style, padding: 0}}))
.catch(() => this.setState({src: 'img/broken_image.png'}));
.catch(_ => this.setState({src: 'img/broken_image.png'}));
}
}
+4 -4
View File
@@ -91,7 +91,7 @@ class TopicSecurity extends React.PureComponent {
this.props.onShowAlert(
formatMessage(messages.topic_delete), // title
formatMessage(messages.topic_delete_warning), // content
(() => { this.props.onDeleteTopic(this.props.topic); }), // onConfirm
_ => this.props.onDeleteTopic(this.props.topic), // onConfirm
null, // "OK"
true, // Show Reject button
null // "Cancel"
@@ -104,7 +104,7 @@ class TopicSecurity extends React.PureComponent {
this.props.onShowAlert(
formatMessage(this.props.deleter ? messages.delete_messages : messages.clear_messages), // title
formatMessage(this.props.deleter ? messages.delete_messages_warning : messages.clear_messages_warning), // content
(() => { this.props.onDeleteMessages(this.props.topic); }), // onConfirm
_ => this.props.onDeleteMessages(this.props.topic), // onConfirm
null, // "OK"
true, // Show Reject button
null // "Cancel"
@@ -117,7 +117,7 @@ class TopicSecurity extends React.PureComponent {
this.props.onShowAlert(
formatMessage(messages.leave_chat), // title
formatMessage(messages.leave_chat_warning), // content
(() => { this.props.onLeaveTopic(this.props.topic); }), // onConfirm
_ => this.props.onLeaveTopic(this.props.topic), // onConfirm
null, // "OK"
true, // Show Reject button
null // "Cancel"
@@ -130,7 +130,7 @@ class TopicSecurity extends React.PureComponent {
this.props.onShowAlert(
formatMessage(messages.block_contact), // title
formatMessage(messages.block_contact_warning), // content
(() => { this.props.onBlockTopic(this.props.topic); }), // onConfirm
_ => this.props.onBlockTopic(this.props.topic), // onConfirm
null, // "OK"
true, // Show Reject button
null // "Cancel"
+1 -1
View File
@@ -52,7 +52,7 @@ export default class VisiblePassword extends React.PureComponent {
handleEditingFinished(e) {
if (e) {
let currentTarget = e.currentTarget;
setTimeout(() => {
setTimeout(_ => {
if (!currentTarget.contains(document.activeElement)) {
if (this.props.onFinished) {
this.props.onFinished(this.state.value);