Browse Source

Fixed ESLint error (#15214)

* eslint --fix

* fix consistent-return

* fix promise/catch-or-return

* ignore import rule
master
abcang 3 years ago
committed by GitHub
parent
commit
a2da02626e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 13 deletions
  1. +1
    -1
      app/javascript/mastodon/actions/notifications.js
  2. +2
    -0
      app/javascript/mastodon/features/ui/components/focal_point_modal.js
  3. +1
    -1
      app/javascript/mastodon/stream.js
  4. +2
    -1
      app/javascript/mastodon/utils/notifications.js
  5. +13
    -10
      streaming/index.js

+ 1
- 1
app/javascript/mastodon/actions/notifications.js View File

@ -257,7 +257,7 @@ export function setupBrowserNotifications() {
if ('Notification' in window && 'permissions' in navigator) { if ('Notification' in window && 'permissions' in navigator) {
navigator.permissions.query({ name: 'notifications' }).then((status) => { navigator.permissions.query({ name: 'notifications' }).then((status) => {
status.onchange = () => dispatch(setBrowserPermission(Notification.permission)); status.onchange = () => dispatch(setBrowserPermission(Notification.permission));
});
}).catch(console.warn);
} }
}; };
} }

+ 2
- 0
app/javascript/mastodon/features/ui/components/focal_point_modal.js View File

@ -18,7 +18,9 @@ import { length } from 'stringz';
import { Tesseract as fetchTesseract } from 'mastodon/features/ui/util/async-components'; import { Tesseract as fetchTesseract } from 'mastodon/features/ui/util/async-components';
import GIFV from 'mastodon/components/gifv'; import GIFV from 'mastodon/components/gifv';
import { me } from 'mastodon/initial_state'; import { me } from 'mastodon/initial_state';
// eslint-disable-next-line import/no-extraneous-dependencies
import tesseractCorePath from 'tesseract.js-core/tesseract-core.wasm.js'; import tesseractCorePath from 'tesseract.js-core/tesseract-core.wasm.js';
// eslint-disable-next-line import/extensions
import tesseractWorkerPath from 'tesseract.js/dist/worker.min.js'; import tesseractWorkerPath from 'tesseract.js/dist/worker.min.js';
import { assetHost } from 'mastodon/utils/config'; import { assetHost } from 'mastodon/utils/config';

+ 1
- 1
app/javascript/mastodon/stream.js View File

@ -16,7 +16,7 @@ let sharedConnection;
* @property {function(): void} onDisconnect * @property {function(): void} onDisconnect
*/ */
/**
/**
* @typedef StreamEvent * @typedef StreamEvent
* @property {string} event * @property {string} event
* @property {object} payload * @property {object} payload

+ 2
- 1
app/javascript/mastodon/utils/notifications.js View File

@ -3,6 +3,7 @@
const checkNotificationPromise = () => { const checkNotificationPromise = () => {
try { try {
// eslint-disable-next-line promise/catch-or-return
Notification.requestPermission().then(); Notification.requestPermission().then();
} catch(e) { } catch(e) {
return false; return false;
@ -22,7 +23,7 @@ const handlePermission = (permission, callback) => {
export const requestNotificationPermission = (callback) => { export const requestNotificationPermission = (callback) => {
if (checkNotificationPromise()) { if (checkNotificationPromise()) {
Notification.requestPermission().then((permission) => handlePermission(permission, callback));
Notification.requestPermission().then((permission) => handlePermission(permission, callback)).catch(console.warn);
} else { } else {
Notification.requestPermission((permission) => handlePermission(permission, callback)); Notification.requestPermission((permission) => handlePermission(permission, callback));
} }

+ 13
- 10
streaming/index.js View File

@ -230,13 +230,13 @@ const startWorker = (workerId) => {
const FALSE_VALUES = [ const FALSE_VALUES = [
false, false,
0, 0,
"0";,
"f";,
"F";,
"false";,
"FALSE";,
"off";,
"OFF"
'0';,
'f';,
'F';,
'false';,
'FALSE';,
'off';,
'OFF',
]; ];
/** /**
@ -377,6 +377,8 @@ const startWorker = (workerId) => {
return 'direct'; return 'direct';
case '/api/v1/streaming/list': case '/api/v1/streaming/list':
return 'list'; return 'list';
default:
return undefined;
} }
}; };
@ -475,7 +477,7 @@ const startWorker = (workerId) => {
log.verbose(req.requestId, `Closing connection for ${req.accountId} due to expired access token`); log.verbose(req.requestId, `Closing connection for ${req.accountId} due to expired access token`);
eventHandlers.onKill(); eventHandlers.onKill();
} }
}
};
}; };
/** /**
@ -530,7 +532,8 @@ const startWorker = (workerId) => {
log.error(req.requestId, err.toString()); log.error(req.requestId, err.toString());
if (res.headersSent) { if (res.headersSent) {
return next(err);
next(err);
return;
} }
res.writeHead(err.status || 500, { 'Content-Type': 'application/json' }); res.writeHead(err.status || 500, { 'Content-Type': 'application/json' });
@ -1032,7 +1035,7 @@ const startWorker = (workerId) => {
if (type === 'subscribe') { if (type === 'subscribe') {
subscribeWebsocketToChannel(session, firstParam(stream), params); subscribeWebsocketToChannel(session, firstParam(stream), params);
} else if (type === 'unsubscribe') { } else if (type === 'unsubscribe') {
unsubscribeWebsocketFromChannel(session, firstParam(stream), params)
unsubscribeWebsocketFromChannel(session, firstParam(stream), params);
} else { } else {
// Unknown action type // Unknown action type
} }

Loading…
Cancel
Save