Add tests, fix firebase
This commit is contained in:
@@ -202,9 +202,10 @@ class SubscriptionManager {
|
||||
|
||||
/** Adds/replaces notifications, will not throw if they exist */
|
||||
async addNotifications(subscriptionId, notifications) {
|
||||
const notificationsWithSubscriptionId = notifications.map((notification) => {
|
||||
return { ...messageWithSequenceId(notification), subscriptionId };
|
||||
});
|
||||
const notificationsWithSubscriptionId = notifications.map((notification) => ({
|
||||
...messageWithSequenceId(notification),
|
||||
subscriptionId,
|
||||
}));
|
||||
const lastNotificationId = notifications.at(-1).id;
|
||||
await this.db.notifications.bulkPut(notificationsWithSubscriptionId);
|
||||
await this.db.subscriptions.update(subscriptionId, {
|
||||
|
||||
@@ -50,7 +50,7 @@ export const isImage = (attachment) => {
|
||||
export const icon = "/static/images/ntfy.png";
|
||||
export const badge = "/static/images/mask-icon.svg";
|
||||
|
||||
export const toNotificationParams = ({ subscriptionId, message, defaultTitle, topicRoute }) => {
|
||||
export const toNotificationParams = ({ message, defaultTitle, topicRoute }) => {
|
||||
const image = isImage(message.attachment) ? message.attachment.url : undefined;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API
|
||||
|
||||
@@ -104,10 +104,10 @@ export const maybeActionErrors = (notification) => {
|
||||
};
|
||||
|
||||
export const messageWithSequenceId = (message) => {
|
||||
if (!message.sequenceId) {
|
||||
message.sequenceId = message.sequence_id || message.id;
|
||||
if (message.sequenceId) {
|
||||
return message;
|
||||
}
|
||||
return message;
|
||||
return { ...message, sequenceId: message.sequence_id || message.id };
|
||||
};
|
||||
|
||||
export const shuffle = (arr) => {
|
||||
|
||||
Reference in New Issue
Block a user