Add 'Topics' page to show latest root posts
Problem: @masukomi pointed out that the 'latest' view doesn't show the awesome slice of content that you'll see if you just look at root posts. Solution: Let's experiment with them! This commit adds a 'Topics' page that has the latest root posts from people you're following.
This commit is contained in:
parent
c2ea8f7cb5
commit
7f40a99799
12
src/index.js
12
src/index.js
|
@ -121,15 +121,15 @@ router
|
|||
ctx.body = await publicPopular({ period });
|
||||
})
|
||||
.get("/public/latest", async ctx => {
|
||||
const publicLatest = async () => {
|
||||
const messages = await post.latest();
|
||||
return publicView({ messages });
|
||||
};
|
||||
ctx.body = await publicLatest();
|
||||
const messages = await post.latest();
|
||||
ctx.body = await publicView({ messages });
|
||||
})
|
||||
.get("/public/latest/extended", async ctx => {
|
||||
const messages = await post.latestExtended();
|
||||
|
||||
ctx.body = await publicView({ messages });
|
||||
})
|
||||
.get("/public/latest/topics", async ctx => {
|
||||
const messages = await post.latestTopics();
|
||||
ctx.body = await publicView({ messages });
|
||||
})
|
||||
.get("/author/:feed", async ctx => {
|
||||
|
|
|
@ -679,6 +679,44 @@ module.exports = cooler => {
|
|||
|
||||
return messages;
|
||||
},
|
||||
latestTopics: async () => {
|
||||
const ssb = await cooler.connect();
|
||||
|
||||
const myFeedId = ssb.id;
|
||||
|
||||
const options = configure({
|
||||
type: "post",
|
||||
private: false
|
||||
});
|
||||
|
||||
const source = await cooler.read(ssb.messagesByType, options);
|
||||
|
||||
const extendedFilter = await socialFilter({
|
||||
following: true
|
||||
});
|
||||
|
||||
const messages = await new Promise((resolve, reject) => {
|
||||
pull(
|
||||
source,
|
||||
pull.filter(
|
||||
message =>
|
||||
typeof message.value.content !== "string" &&
|
||||
message.value.content.root == null
|
||||
),
|
||||
extendedFilter,
|
||||
pull.take(maxMessages),
|
||||
pull.collect((err, collectedMessages) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(transform(ssb, collectedMessages, myFeedId));
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
return messages;
|
||||
},
|
||||
popular: async ({ period }) => {
|
||||
const ssb = await cooler.connect();
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ module.exports = (...elements) => {
|
|||
li(a({ href: "/public/latest/extended" }, "🗺️ Extended")),
|
||||
li(a({ href: "/" }, "📣 Popular")),
|
||||
li(a({ href: "/public/latest" }, "🐇 Latest")),
|
||||
li(a({ href: "/public/latest/topics" }, "📖 Topics")),
|
||||
li(a({ href: "/profile" }, "🐱 Profile")),
|
||||
li(a({ href: "/mentions" }, "💬 Mentions")),
|
||||
li(a({ href: "/inbox" }, "✉️ Private")),
|
||||
|
|
Loading…
Reference in New Issue