forked from Mirrors/elk
refactor: removeFilteredItems function
This commit is contained in:
parent
853c65c056
commit
a5c779aa2e
1 changed files with 8 additions and 4 deletions
|
@ -9,14 +9,18 @@ function areStatusesConsecutive(a: mastodon.v1.Status, b: mastodon.v1.Status) {
|
||||||
return !!inReplyToId && (inReplyToId === a.reblog?.id || inReplyToId === a.id)
|
return !!inReplyToId && (inReplyToId === a.reblog?.id || inReplyToId === a.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reorderedTimeline(items: mastodon.v1.Status[], context: mastodon.v1.FilterContext) {
|
function removeFilteredItems(items: mastodon.v1.Status[], context: mastodon.v1.FilterContext): mastodon.v1.Status[] {
|
||||||
let steps = 0
|
|
||||||
|
|
||||||
const isStrict = (filter: mastodon.v1.FilterResult) => filter.filter.filterAction === 'hide' && filter.filter.context.includes(context)
|
const isStrict = (filter: mastodon.v1.FilterResult) => filter.filter.filterAction === 'hide' && filter.filter.context.includes(context)
|
||||||
const isFiltered = (item: mastodon.v1.Status) => !item.filtered?.find(isStrict)
|
const isFiltered = (item: mastodon.v1.Status) => !item.filtered?.find(isStrict)
|
||||||
const isReblogFiltered = (item: mastodon.v1.Status) => !item.reblog?.filtered?.find(isStrict)
|
const isReblogFiltered = (item: mastodon.v1.Status) => !item.reblog?.filtered?.find(isStrict)
|
||||||
|
|
||||||
const newItems = [...items].filter(isFiltered).filter(isReblogFiltered)
|
return [...items].filter(isFiltered).filter(isReblogFiltered)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function reorderedTimeline(items: mastodon.v1.Status[], context: mastodon.v1.FilterContext) {
|
||||||
|
let steps = 0
|
||||||
|
|
||||||
|
const newItems = removeFilteredItems(items, context)
|
||||||
|
|
||||||
for (let i = newItems.length - 1; i > 0; i--) {
|
for (let i = newItems.length - 1; i > 0; i--) {
|
||||||
for (let k = 1; k <= maxDistance && i - k >= 0; k++) {
|
for (let k = 1; k <= maxDistance && i - k >= 0; k++) {
|
||||||
|
|
Loading…
Reference in a new issue