1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-23 19:59:26 +01:00

Make small code style improvements

This commit is contained in:
nimbleghost 2023-05-24 20:47:19 +02:00
parent be6d962cc3
commit 025ea3c1d6
3 changed files with 4 additions and 16 deletions

View file

@ -61,9 +61,7 @@ class ConnectionManager {
const { connectionId } = subscription; const { connectionId } = subscription;
const added = !this.connections.get(connectionId); const added = !this.connections.get(connectionId);
if (added) { if (added) {
const { baseUrl } = subscription; const { baseUrl, topic, user } = subscription;
const { topic } = subscription;
const { user } = subscription;
const since = subscription.last; const since = subscription.last;
const connection = new Connection( const connection = new Connection(
connectionId, connectionId,

View file

@ -118,10 +118,10 @@ export const maybeWithBearerAuth = (headers, token) => {
export const withBasicAuth = (headers, username, password) => ({ ...headers, Authorization: basicAuth(username, password) }); export const withBasicAuth = (headers, username, password) => ({ ...headers, Authorization: basicAuth(username, password) });
export const maybeWithAuth = (headers, user) => { export const maybeWithAuth = (headers, user) => {
if (user && user.password) { if (user?.password) {
return withBasicAuth(headers, user.username, user.password); return withBasicAuth(headers, user.username, user.password);
} }
if (user && user.token) { if (user?.token) {
return withBearerAuth(headers, user.token); return withBearerAuth(headers, user.token);
} }
return headers; return headers;

View file

@ -125,17 +125,7 @@ const Category = (props) => {
); );
}; };
const emojiMatches = (emoji, words) => { const emojiMatches = (emoji, words) => words.length === 0 || words.some((word) => emoji.searchBase.includes(word));
if (words.length === 0) {
return true;
}
for (const word of words) {
if (emoji.searchBase.indexOf(word) === -1) {
return false;
}
}
return true;
};
const Emoji = (props) => { const Emoji = (props) => {
const { emoji } = props; const { emoji } = props;