Add PWA, service worker and Web Push

- Use new notification request/opt-in flow for push
- Implement unsubscribing
- Implement muting
- Implement emojis in title
- Add iOS specific PWA warning
- Don’t use websockets when web push is enabled
- Fix duplicate notifications
- Implement default web push setting
- Implement changing subscription type
- Implement web push subscription refresh
- Implement web push notification click
This commit is contained in:
nimbleghost
2023-05-24 21:36:01 +02:00
parent 733ef4664b
commit ff5c854192
53 changed files with 4363 additions and 249 deletions

View File

@@ -1,9 +1,13 @@
import db from "./db";
import getDb from "./getDb";
import session from "./Session";
class UserManager {
constructor(db) {
this.db = db;
}
async all() {
const users = await db.users.toArray();
const users = await this.db.users.toArray();
if (session.exists()) {
users.unshift(this.localUser());
}
@@ -14,21 +18,21 @@ class UserManager {
if (session.exists() && baseUrl === config.base_url) {
return this.localUser();
}
return db.users.get(baseUrl);
return this.db.users.get(baseUrl);
}
async save(user) {
if (session.exists() && user.baseUrl === config.base_url) {
return;
}
await db.users.put(user);
await this.db.users.put(user);
}
async delete(baseUrl) {
if (session.exists() && baseUrl === config.base_url) {
return;
}
await db.users.delete(baseUrl);
await this.db.users.delete(baseUrl);
}
localUser() {
@@ -43,5 +47,4 @@ class UserManager {
}
}
const userManager = new UserManager();
export default userManager;
export default new UserManager(getDb());