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];
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'}`);
}
import { PlatformServiceName } from '@limetech/lime-web-components';
const repository = platform.get(PlatformServiceName.NotificationRepository);
const response = await repository.loadAll({ filter: { read: false } });
for (const notification of response.items) {
await repository.markAsRead(notification, true);
}
console.log(`Marked ${response.items.length} notifications 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