BetaBetaDelete a notification.
Permanently removes the notification for the current user. This operation cannot be undone. The notification will be removed from:
The Notification to delete
Promise that resolves when deletion is complete
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const response = await repository.loadAll({ limit: 1 });
const [notification] = response.items;
if (notification) {
try {
await repository.delete(notification);
} catch (error) {
console.error('Failed to delete:', error);
}
}
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const response = await repository.loadAll({ filter: { read: true } });
for (const notification of response.items) {
await repository.delete(notification);
}
console.log(`Cleared ${response.items.length} read notifications`);
BetaGet a cached notification by ID.
Retrieves a notification from the repository cache without making a network request.
Returns undefined if the notification has not been loaded or doesn't exist.
Use this to access notifications that were previously loaded via loadAll.
ID of the notification to retrieve
The cached Notification, or undefined if not found
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const notificationId = 1001;
const notification = repository.get(notificationId);
if (notification) {
console.log('Type:', notification.type);
console.log('Read:', notification.read !== undefined);
} else {
console.log('Notification not in cache');
}
BetaLoad notifications for the current user.
Fetches notifications from the server with optional filtering and pagination. Returns both the notification items and count information (total and unread).
Use NotificationLoadOptions to:
Optionaloptions: NotificationLoadOptionsConfiguration for loading notifications
Promise resolving to NotificationResponse with items and counts
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const pageSize = 20;
const pageNumber = 2;
const response = await repository.loadAll({
limit: pageSize,
offset: pageNumber * pageSize,
});
const totalPages = Math.ceil(response.count.total / pageSize);
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const seen = await repository.loadAll({ limit: 1 });
const lastNotificationId = seen.items[0]?.id;
const response = await repository.loadAll({
newerThan: lastNotificationId,
limit: 100,
});
if (response.items.length > 0) {
console.log(`${response.items.length} new notifications`);
}
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const firstPage = await repository.loadAll({ limit: 25 });
let notifications = firstPage.items;
const oldestId = notifications.at(-1)?.id;
const response = await repository.loadAll({
olderThan: oldestId,
limit: 25,
});
notifications = [...notifications, ...response.items];
BetaLoad the current user's notifications grouped into bundles, one per object they are about.
Notifications are filtered before they are grouped, so with
filter: { read: false } a bundle holds only unread notifications.
Read notifications are included for a limited time after they were
read, and a bundle holds only its newest notifications. Older ones are
in the object's activity feed.
Bundles are ordered by their newest notification. To page, pass the id
of the newest notification in the last bundle as olderThan, or in
the first bundle as newerThan.
Loaded notifications are cached, so NotificationRepository.get finds them.
The response sends each object once; the repository returns them resolved.
Optionaloptions: NotificationBundleLoadOptionsoptions to load the notification bundles with.
limit counts notification bundles.
the bundles, and counts of all the user's notifications
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const response = await repository.loadBundles({
limit: 10,
notificationsPerBundle: 5,
});
for (const bundle of response.items) {
const onlyInFeed = bundle.count.total - bundle.notifications.length;
console.log(bundle.id, bundle.count.unread, onlyInFeed);
}
BetaMark all of the current user's unread notifications as read.
the number of notifications that were marked as read
BetaMark a notification as read or unread.
Updates the read status of a notification. When marked as read, the notification's
read property is set to the current timestamp. When marked as unread, the read
property is cleared.
Marking as read is typically done when:
The Notification to update
Optionalread: booleanWhether to mark as read (true) or unread (false). Defaults to true
Promise resolving to the updated Notification
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const navigatorService = platform.get(PlatformServiceName.Navigator);
const response = await repository.loadAll({ limit: 1 });
const [notification] = response.items;
if (notification && !notification.read) {
try {
await repository.markAsRead(notification);
const limeobject = notification.limeobject;
if (limeobject) {
navigatorService.navigate(
`/object/${limeobject.getLimetype().name}/${limeobject.id}`
);
}
} catch (error) {
console.error('Failed to mark as read:', error);
}
}
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const response = await repository.loadAll({ limit: 1 });
const [notification] = response.items;
if (notification) {
const shouldBeRead = !notification.read;
await repository.markAsRead(notification, shouldBeRead);
console.log(`Marked as ${shouldBeRead ? 'read' : 'unread'}`);
}
BetaMark the current user's unread notifications in a bundle as read, including those that were not loaded with it.
the NotificationBundle to mark as read
the number of notifications that were marked as read
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const { items } = await repository.loadBundles();
const [bundle] = items;
if (bundle) {
const count = await repository.markBundleAsRead(bundle);
console.log(`Marked ${count} notifications in ${bundle.id} as read`);
}
Repository for managing user notifications.
NotificationRepository provides methods to load, manage, and interact with notifications for the current user. Notifications inform users about:
Each Notification contains:
Example: Display notification list
The repository methods are generic in
Tso callers can supply the expected shape of Notification.data on a per-call basis. The default isunknown— narrow it at the call site when you know what payload to expect, e.g.repo.get<MentionData>(id).See