about summary refs log tree commit diff
path: root/src/lib/api/feed-manip.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-05-02 23:06:55 -0500
committerGitHub <noreply@github.com>2023-05-02 23:06:55 -0500
commit6f1c4ec9a9b5b7d0b4b67f3bc7c3af6810da5001 (patch)
tree80401e47119aa52ac188a290d140ae56686162bb /src/lib/api/feed-manip.ts
parent95f8360d19938d00aaf9036a76616a7b82093703 (diff)
downloadvoidsky-6f1c4ec9a9b5b7d0b4b67f3bc7c3af6810da5001.tar.zst
[APP-549] Language controls for Whats Hot (#563)
* Add a content-language preference control

* Update whats hot to only show the selected languages and to refresh on lang pref changes

* Fix lint

* Fix tests

* Add missing accessibility role
Diffstat (limited to 'src/lib/api/feed-manip.ts')
-rw-r--r--src/lib/api/feed-manip.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts
index 60e755048..96534d1ba 100644
--- a/src/lib/api/feed-manip.ts
+++ b/src/lib/api/feed-manip.ts
@@ -202,7 +202,9 @@ export class FeedTuner {
       tuner: FeedTuner,
       slices: FeedViewPostsSlice[],
     ): FeedViewPostsSlice[] => {
-      const origSlices = slices.concat()
+      if (!langsCode2.length) {
+        return slices
+      }
       for (let i = slices.length - 1; i >= 0; i--) {
         let hasPreferredLang = false
         for (const item of slices[i].items) {
@@ -236,11 +238,7 @@ export class FeedTuner {
           slices.splice(i, 1)
         }
       }
-      if (slices.length) {
-        return slices
-      }
-      // fallback: give everything if the language filter left nothing
-      return origSlices
+      return slices
     }
   }
 }