Rename to sequence_id
This commit is contained in:
@@ -2,7 +2,7 @@ import api from "./Api";
|
||||
import notifier from "./Notifier";
|
||||
import prefs from "./Prefs";
|
||||
import db from "./db";
|
||||
import { messageWithSID, topicUrl } from "./utils";
|
||||
import { messageWithSequenceId, topicUrl } from "./utils";
|
||||
|
||||
class SubscriptionManager {
|
||||
constructor(dbImpl) {
|
||||
@@ -15,7 +15,7 @@ class SubscriptionManager {
|
||||
return Promise.all(
|
||||
subscriptions.map(async (s) => ({
|
||||
...s,
|
||||
new: await this.db.notifications.where({ subscriptionId: s.id, new: 1 }).count()
|
||||
new: await this.db.notifications.where({ subscriptionId: s.id, new: 1 }).count(),
|
||||
}))
|
||||
);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class SubscriptionManager {
|
||||
baseUrl,
|
||||
topic,
|
||||
mutedUntil: 0,
|
||||
last: null
|
||||
last: null,
|
||||
};
|
||||
|
||||
await this.db.subscriptions.put(subscription);
|
||||
@@ -101,7 +101,7 @@ class SubscriptionManager {
|
||||
|
||||
const local = await this.add(remote.base_url, remote.topic, {
|
||||
displayName: remote.display_name, // May be undefined
|
||||
reservation // May be null!
|
||||
reservation, // May be null!
|
||||
});
|
||||
|
||||
return local.id;
|
||||
@@ -183,15 +183,15 @@ class SubscriptionManager {
|
||||
|
||||
// Add notification to database
|
||||
await this.db.notifications.add({
|
||||
...messageWithSID(notification),
|
||||
...messageWithSequenceId(notification),
|
||||
subscriptionId,
|
||||
new: 1 // New marker (used for bubble indicator); cannot be boolean; Dexie index limitation
|
||||
new: 1, // New marker (used for bubble indicator); cannot be boolean; Dexie index limitation
|
||||
});
|
||||
|
||||
// FIXME consider put() for double tab
|
||||
// Update subscription last message id (for ?since=... queries)
|
||||
await this.db.subscriptions.update(subscriptionId, {
|
||||
last: notification.id
|
||||
last: notification.id,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(`[SubscriptionManager] Error adding notification`, e);
|
||||
@@ -202,12 +202,12 @@ class SubscriptionManager {
|
||||
/** Adds/replaces notifications, will not throw if they exist */
|
||||
async addNotifications(subscriptionId, notifications) {
|
||||
const notificationsWithSubscriptionId = notifications.map((notification) => {
|
||||
return { ...messageWithSID(notification), subscriptionId };
|
||||
return { ...messageWithSequenceId(notification), subscriptionId };
|
||||
});
|
||||
const lastNotificationId = notifications.at(-1).id;
|
||||
await this.db.notifications.bulkPut(notificationsWithSubscriptionId);
|
||||
await this.db.subscriptions.update(subscriptionId, {
|
||||
last: lastNotificationId
|
||||
last: lastNotificationId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ class SubscriptionManager {
|
||||
await this.db.notifications.delete(notificationId);
|
||||
}
|
||||
|
||||
async deleteNotificationBySid(subscriptionId, sid) {
|
||||
await this.db.notifications.where({ subscriptionId, sid }).delete();
|
||||
async deleteNotificationBySequenceId(subscriptionId, sequenceId) {
|
||||
await this.db.notifications.where({ subscriptionId, sequenceId }).delete();
|
||||
}
|
||||
|
||||
async deleteNotifications(subscriptionId) {
|
||||
@@ -240,8 +240,8 @@ class SubscriptionManager {
|
||||
await this.db.notifications.where({ id: notificationId }).modify({ new: 0 });
|
||||
}
|
||||
|
||||
async markNotificationReadBySid(subscriptionId, sid) {
|
||||
await this.db.notifications.where({ subscriptionId, sid }).modify({ new: 0 });
|
||||
async markNotificationReadBySequenceId(subscriptionId, sequenceId) {
|
||||
await this.db.notifications.where({ subscriptionId, sequenceId }).modify({ new: 0 });
|
||||
}
|
||||
|
||||
async markNotificationsRead(subscriptionId) {
|
||||
@@ -250,19 +250,19 @@ class SubscriptionManager {
|
||||
|
||||
async setMutedUntil(subscriptionId, mutedUntil) {
|
||||
await this.db.subscriptions.update(subscriptionId, {
|
||||
mutedUntil
|
||||
mutedUntil,
|
||||
});
|
||||
}
|
||||
|
||||
async setDisplayName(subscriptionId, displayName) {
|
||||
await this.db.subscriptions.update(subscriptionId, {
|
||||
displayName
|
||||
displayName,
|
||||
});
|
||||
}
|
||||
|
||||
async setReservation(subscriptionId, reservation) {
|
||||
await this.db.subscriptions.update(subscriptionId, {
|
||||
reservation
|
||||
reservation,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user