Onboarding tweaks (#272)

* Small fix to side menu rendering

* Change onboarding to use an explicit 'is onboarding' mode to more clearly control the flow

* Add a progress bar to the welcome banner

* Dont show the 'unfollow button' on posts in weird times (close #271)

* Improve the empty state of the feed

* Only suggest recent posts
This commit is contained in:
Paul Frazee 2023-03-06 15:34:22 -06:00 committed by GitHub
parent 74c30c60b8
commit 36791e68b3
13 changed files with 259 additions and 123 deletions

View file

@ -37,13 +37,20 @@ function mergePosts(
// filter the feed down to the post with the most upvotes
res.data.feed = res.data.feed.reduce(
(acc: AppBskyFeedFeedViewPost.Main[], v) => {
if (!acc?.[0] && !v.reason) {
if (
!acc?.[0] &&
!v.reason &&
!v.reply &&
isRecentEnough(v.post.indexedAt)
) {
return [v]
}
if (
acc &&
!v.reason &&
v.post.upvoteCount > acc[0].post.upvoteCount
!v.reply &&
v.post.upvoteCount > acc[0]?.post.upvoteCount &&
isRecentEnough(v.post.indexedAt)
) {
return [v]
}
@ -112,6 +119,16 @@ function isCombinedCursor(cursor: string) {
return cursor.includes(',')
}
const TWO_DAYS_AGO = Date.now() - 1e3 * 60 * 60 * 48
function isRecentEnough(date: string) {
try {
const d = Number(new Date(date))
return d > TWO_DAYS_AGO
} catch {
return false
}
}
export {
getMultipleAuthorsPosts,
mergePosts,