mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-05-19 11:53:26 +12:00
ff5c854192
- 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
42 lines
735 B
JavaScript
42 lines
735 B
JavaScript
import sessionReplica from "./SessionReplica";
|
|
|
|
class Session {
|
|
constructor(replica) {
|
|
this.replica = replica;
|
|
}
|
|
|
|
store(username, token) {
|
|
localStorage.setItem("user", username);
|
|
localStorage.setItem("token", token);
|
|
|
|
this.replica.store(username, token);
|
|
}
|
|
|
|
reset() {
|
|
localStorage.removeItem("user");
|
|
localStorage.removeItem("token");
|
|
|
|
this.replica.reset();
|
|
}
|
|
|
|
resetAndRedirect(url) {
|
|
this.reset();
|
|
window.location.href = url;
|
|
}
|
|
|
|
exists() {
|
|
return this.username() && this.token();
|
|
}
|
|
|
|
username() {
|
|
return localStorage.getItem("user");
|
|
}
|
|
|
|
token() {
|
|
return localStorage.getItem("token");
|
|
}
|
|
}
|
|
|
|
const session = new Session(sessionReplica);
|
|
export default session;
|