Exemple #1
0
 .then(({ allLinks, approvedLinks }) => {
   const approved = reduce((a, l) => ({ ...a, [get(["data", "id"], l)]: true }), {}, approvedLinks);
   allLinks = allLinks.map(link => approved[get(["data", "id"], link)] ? link : ({
     ...link, data: { ...link.data, banned_by: !link.data.stickied && "moderators" }
   }));
   const viewed = find(compose(eq(get(["data", "id"], thing)), get(["data", "id"])), allLinks) || thing;
   const others = filter(not(eq(viewed)), uniqThings(allLinks.concat(approvedLinks)));
   return { viewed, others };
 })
Exemple #2
0
 .then(() => effects.onFetchThings(path, params)).then((state) => {
   const idIndexMap = {}, frontpageWatchMap = {};
   return compose(
     effects.onFetchNames,
     filter(item => !!item), map((item) => {
       const index = parseInt(item.data.title.slice(2, 20).split("|")[0], 10);
       if (!index) return;
       const parts = item.data.url.split("/").filter(i => !!i);
       parts.pop();
       const id = parts.pop();
       idIndexMap[id] = index;
       frontpageWatchMap[id] = item;
       return "t3_" + id;
     }),
     filter(or(
       compose(eq("Frontpage-Watch"), get(["data", "author"])),
       compose(eq("FrontpageWatch"), get(["data", "author"]))
     )),
     get([path, "allChildren"])
   )(state)
     .then(compose(
       filter(and(
         or(
           compose(isRemoved, get(["data", "selftext"])),
           not(get(["data", "is_self"]))
         ),
         get("rank")
       )),
       map((item => ({
         ...item,
         rank: idIndexMap[get(["data", "id"], item)],
         data: {
           ...item.data,
           banned_by: "moderators",
           meta_thing: frontpageWatchMap[get(["data", "id"], item)]
         },
       }))),
       get("named")
     ))
     .then(frontpageWatch => state => ({
       ...state,
       frontpageWatch: uniqThings(frontpageWatch.concat(state.frontpageWatch || []))
     }));
 });
Exemple #3
0
const filtered = status =>
  compose(
    filter(
      compose(
        eq(status),
        get("status")
      )
    ),
    apiUnvettedProposals
  );
Exemple #4
0
 .then(allLinks => {
   allLinks.push(thing);
   allLinks = uniqThings(allLinks);
   const other = find(compose(not(eq(get(["data", "id"], thing))), get(["data", "id"])), allLinks);
   if (!other) return { allLinks, approvedLinks: [thing] };
   const dupes1Path = get(["data", "permalink"], thing).replace("/comments/", "/duplicates/");
   const dupes2Path = get(["data", "permalink"], other).replace("/comments/", "/duplicates/");
   return Promise.all([
     effects.onFetchThings(dupes1Path, {}, 1).then(get([dupes1Path, "allChildren"])),
     effects.onFetchThings(dupes2Path, {}, 1).then(get([dupes2Path, "allChildren"]))
   ]).then(([dupes1, dupes2]) => uniqThings(dupes1.concat(dupes2)))
     .then(approvedLinks => ({ allLinks: uniqThings(allLinks.concat(approvedLinks)), approvedLinks }));
 })