2023-02-18 18:06:53 +00:00
|
|
|
package com.vitorpamplona.amethyst.ui.dal
|
|
|
|
|
|
|
|
import com.vitorpamplona.amethyst.model.Account
|
|
|
|
import com.vitorpamplona.amethyst.model.LocalCache
|
|
|
|
import com.vitorpamplona.amethyst.model.Note
|
|
|
|
import com.vitorpamplona.amethyst.model.User
|
2023-06-03 16:39:06 +00:00
|
|
|
import com.vitorpamplona.amethyst.service.model.AppRecommendationEvent
|
2023-05-09 16:58:56 +00:00
|
|
|
import com.vitorpamplona.amethyst.service.model.BookmarkListEvent
|
|
|
|
import com.vitorpamplona.amethyst.service.model.PeopleListEvent
|
2023-02-18 18:06:53 +00:00
|
|
|
|
2023-03-07 18:46:44 +00:00
|
|
|
object UserProfileNewThreadFeedFilter : FeedFilter<Note>() {
|
|
|
|
var account: Account? = null
|
|
|
|
var user: User? = null
|
2023-02-18 18:06:53 +00:00
|
|
|
|
2023-05-07 16:51:12 +00:00
|
|
|
fun loadUserProfile(accountLoggedIn: Account, user: User) {
|
2023-03-07 18:46:44 +00:00
|
|
|
account = accountLoggedIn
|
2023-05-07 16:51:12 +00:00
|
|
|
this.user = user
|
2023-03-07 18:46:44 +00:00
|
|
|
}
|
2023-02-18 18:06:53 +00:00
|
|
|
|
2023-03-07 18:46:44 +00:00
|
|
|
override fun feed(): List<Note> {
|
2023-05-09 16:58:56 +00:00
|
|
|
val longFormNotes = LocalCache.addressables.values
|
2023-06-03 16:39:06 +00:00
|
|
|
.filter { it.author == user && (it.event !is PeopleListEvent && it.event !is BookmarkListEvent && it.event !is AppRecommendationEvent) }
|
2023-03-03 16:35:29 +00:00
|
|
|
|
2023-03-07 18:46:44 +00:00
|
|
|
return user?.notes
|
|
|
|
?.plus(longFormNotes)
|
|
|
|
?.filter { account?.isAcceptable(it) == true && it.isNewThread() }
|
2023-05-16 15:10:17 +00:00
|
|
|
?.sortedWith(compareBy({ it.createdAt() }, { it.idHex }))
|
2023-03-07 18:46:44 +00:00
|
|
|
?.reversed() ?: emptyList()
|
|
|
|
}
|
2023-03-05 17:08:49 +00:00
|
|
|
}
|