Refactor to make it more like the Android app

This commit is contained in:
Philipp Heckel
2022-02-23 20:30:12 -05:00
parent 415ab57749
commit 3fac1c3432
9 changed files with 196 additions and 111 deletions

View File

@@ -6,24 +6,35 @@ export default class Subscription {
topic = '';
notifications = [];
lastActive = null;
constructor(baseUrl, topic) {
this.id = topicUrl(baseUrl, topic);
this.baseUrl = baseUrl;
this.topic = topic;
}
addNotification(notification) {
if (notification.time === null) {
return;
return this;
}
this.notifications.push(notification);
this.lastActive = notification.time;
return this;
}
addNotifications(notifications) {
notifications.forEach(n => this.addNotification(n));
return this;
}
url() {
return this.id;
}
wsUrl() {
return topicUrlWs(this.baseUrl, this.topic);
}
shortUrl() {
return shortTopicUrl(this.baseUrl, this.topic);
}