1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-07-04 18:14:45 +02:00

Make manual eslint fixes

These are safe fixes, more complicated fixes can be done separately
(just disabled those errors for now).

- Reorder declarations to fix `no-use-before-define`
- Rename parameters for `no-shadow`
- Remove unused parameters, functions, imports
- Switch from `++` and `—` to `+= 1` and `-= 1` for `no-unary`
- Use object spreading instead of parameter reassignment in auth utils
- Use `window.location` instead of `location` global
- Use inline JSX strings instead of unescaped values
-
This commit is contained in:
nimbleghost 2023-05-24 10:20:15 +02:00
parent 8319f1cf26
commit 59011c8a32
20 changed files with 369 additions and 351 deletions

View file

@ -7,6 +7,7 @@ class SubscriptionManager {
const subscriptions = await db.subscriptions.toArray();
await Promise.all(
subscriptions.map(async (s) => {
// eslint-disable-next-line no-param-reassign
s.new = await db.notifications.where({ subscriptionId: s.id, new: 1 }).count();
})
);
@ -14,7 +15,7 @@ class SubscriptionManager {
}
async get(subscriptionId) {
return await db.subscriptions.get(subscriptionId);
return db.subscriptions.get(subscriptionId);
}
async add(baseUrl, topic, internal) {
@ -40,10 +41,14 @@ class SubscriptionManager {
// Add remote subscriptions
const remoteIds = []; // = topicUrl(baseUrl, topic)
for (let i = 0; i < remoteSubscriptions.length; i++) {
for (let i = 0; i < remoteSubscriptions.length; i += 1) {
const remote = remoteSubscriptions[i];
// TODO(eslint): Switch to Promise.all
// eslint-disable-next-line no-await-in-loop
const local = await this.add(remote.base_url, remote.topic, false);
const reservation = remoteReservations?.find((r) => remote.base_url === config.base_url && remote.topic === r.topic) || null;
// TODO(eslint): Switch to Promise.all
// eslint-disable-next-line no-await-in-loop
await this.update(local.id, {
displayName: remote.display_name, // May be undefined
reservation, // May be null!
@ -53,10 +58,12 @@ class SubscriptionManager {
// Remove local subscriptions that do not exist remotely
const localSubscriptions = await db.subscriptions.toArray();
for (let i = 0; i < localSubscriptions.length; i++) {
for (let i = 0; i < localSubscriptions.length; i += 1) {
const local = localSubscriptions[i];
const remoteExists = remoteIds.includes(local.id);
if (!local.internal && !remoteExists) {
// TODO(eslint): Switch to Promise.all
// eslint-disable-next-line no-await-in-loop
await this.remove(local.id);
}
}
@ -101,6 +108,7 @@ class SubscriptionManager {
return false;
}
try {
// eslint-disable-next-line no-param-reassign
notification.new = 1; // New marker (used for bubble indicator); cannot be boolean; Dexie index limitation
await db.notifications.add({ ...notification, subscriptionId }); // FIXME consider put() for double tab
await db.subscriptions.update(subscriptionId, {