Refactor to make it more like the Android app
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user