Skip to content

Commit c5ea2c3

Browse files
authored
fix: filters applied in activity-timeline (#3473)
1 parent edb4805 commit c5ea2c3

1 file changed

Lines changed: 35 additions & 20 deletions

File tree

frontend/src/modules/activity/components/activity-timeline.vue

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,24 @@ const fetchActivities = async ({ reset } = { reset: false }) => {
311311
if (loading.value) {
312312
return;
313313
}
314-
const filterToApply = {
315-
platform: platform.value ? { in: [platform.value] } : undefined,
316-
};
317314
318-
if (props.entityType === 'member') {
319-
filterToApply.memberId = { in: [props.entity.id] };
320-
} else {
321-
filterToApply.organizationId = { in: [props.entity.id] };
322-
}
315+
// Default filter to apply
316+
const filterToApply: {
317+
and: any[];
318+
} = {
319+
and: [
320+
{
321+
timestamp: {
322+
gte: timestamp.value,
323+
},
324+
},
325+
],
326+
};
323327
324-
if (props.entity.id) {
325-
if (query.value && query.value !== '') {
326-
filterToApply.or = [
328+
// Add search query filter to and clause
329+
if (props.entity.id && !!query.value) {
330+
filterToApply.and.push({
331+
or: [
327332
{
328333
channel: {
329334
textContains: query.value,
@@ -334,17 +339,27 @@ const fetchActivities = async ({ reset } = { reset: false }) => {
334339
textContains: query.value,
335340
},
336341
},
337-
];
338-
}
342+
],
343+
});
339344
}
340345
341-
filterToApply.and = [
342-
{
343-
timestamp: {
344-
gte: timestamp.value,
345-
},
346-
},
347-
];
346+
// Add platform filter to and clause
347+
if (platform.value) {
348+
filterToApply.and.push({
349+
platform: { in: [platform.value] },
350+
});
351+
}
352+
353+
// Add entity filter to and clause
354+
if (props.entityType === 'member') {
355+
filterToApply.and.push({
356+
memberId: { in: [props.entity.id] },
357+
});
358+
} else {
359+
filterToApply.and.push({
360+
organizationId: { in: [props.entity.id] },
361+
});
362+
}
348363
349364
if (reset) {
350365
activities.value.length = 0;

0 commit comments

Comments
 (0)