about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/actions/timelines.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-10-24 17:47:19 +0200
committerThibG <thib@sitedethib.com>2019-10-24 22:09:55 +0200
commit984fce613e51bee54a12e2d42dda5018a870df24 (patch)
tree9d8018b354cd25a3a9f8c19dc052aa3675272b1b /app/javascript/flavours/glitch/actions/timelines.js
parent069e0520c9ab496c4685a9ff1629858d58269f1d (diff)
Change filter logic to keep filtered toots, but not mark them as unread
Keeping them in the TL fixes the front-end not being able to properly keep
track of pagination. Furthermore, filtered toots are not counted as unread
content, whether they are dropped or not.
Diffstat (limited to 'app/javascript/flavours/glitch/actions/timelines.js')
-rw-r--r--app/javascript/flavours/glitch/actions/timelines.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/app/javascript/flavours/glitch/actions/timelines.js b/app/javascript/flavours/glitch/actions/timelines.js
index 482762e35..097878c3b 100644
--- a/app/javascript/flavours/glitch/actions/timelines.js
+++ b/app/javascript/flavours/glitch/actions/timelines.js
@@ -30,12 +30,14 @@ export function updateTimeline(timeline, status, accept) {
       return;
     }
 
-    const dropRegex = getFiltersRegex(getState(), { contextType: timeline })[0];
-
-    if (dropRegex && status.account.id !== me) {
-      if (dropRegex.test(searchTextFromRawStatus(status))) {
-        return;
-      }
+    const filters   = getFiltersRegex(getState(), { contextType: timeline });
+    const dropRegex = filters[0];
+    const regex     = filters[1];
+    const text      = searchTextFromRawStatus(status);
+    let filtered    = false;
+
+    if (status.account.id !== me) {
+      filtered = (dropRegex && dropRegex.test(text)) || (regex && regex.test(text));
     }
 
     dispatch(importFetchedStatus(status));
@@ -45,6 +47,7 @@ export function updateTimeline(timeline, status, accept) {
       timeline,
       status,
       usePendingItems: preferPendingItems,
+      filtered
     });
   };
 };
@@ -107,12 +110,8 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) {
     api(getState).get(path, { params }).then(response => {
       const next = getLinks(response).refs.find(link => link.rel === 'next');
 
-      const dropRegex = getFiltersRegex(getState(), { contextType: timelineId })[0];
-
-      const statuses = dropRegex ? response.data.filter(status => status.account.id === me || !dropRegex.test(searchTextFromRawStatus(status))) : response.data;
-
-      dispatch(importFetchedStatuses(statuses));
-      dispatch(expandTimelineSuccess(timelineId, statuses, next ? next.uri : null, response.status === 206, isLoadingRecent, isLoadingMore, isLoadingRecent && preferPendingItems));
+      dispatch(importFetchedStatuses(response.data));
+      dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.status === 206, isLoadingRecent, isLoadingMore, isLoadingRecent && preferPendingItems));
       done();
     }).catch(error => {
       dispatch(expandTimelineFail(timelineId, error, isLoadingMore));