fix(notifications): handle limit=0 in getNotifications query
Replace falsy guards with explicit undefined checks so that a limit or offset of 0 is not silently discarded. Signed-off-by: Suhrid Marwah <suhridmarwah07@gmail.com>
This commit is contained in:
@@ -469,6 +469,11 @@ describe.each(databases.eachSupportedId())(
|
||||
id3,
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return empty array when limit is 0', async () => {
|
||||
const result = await storage.getNotifications({ user, limit: 0 });
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getNotifications sorting', () => {
|
||||
|
||||
@@ -289,11 +289,11 @@ export class DatabaseNotificationsStore implements NotificationsStore {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.limit) {
|
||||
if (options.limit !== undefined) {
|
||||
query.limit(options.limit);
|
||||
}
|
||||
|
||||
if (options.offset) {
|
||||
if (options.offset !== undefined) {
|
||||
query.offset(options.offset);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user