Revert "some initial work to make it possible to use "unregistered" timelines, i.e. not"
and some stuff to make favorites still work
This reverts commit 039a407400
.
This commit is contained in:
parent
0f8baff5a3
commit
cab87744c8
6 changed files with 38 additions and 43 deletions
|
@ -2,7 +2,7 @@ import { remove, slice, each, find, maxBy, minBy, merge, last, isArray } from 'l
|
|||
import apiService from '../services/api/api.service.js'
|
||||
// import parse from '../services/status_parser/status_parser.js'
|
||||
|
||||
export const emptyTl = (tl, userId = 0) => (Object.assign(tl, {
|
||||
const emptyTl = () => ({
|
||||
statuses: [],
|
||||
statusesObject: {},
|
||||
faves: [],
|
||||
|
@ -14,9 +14,9 @@ export const emptyTl = (tl, userId = 0) => (Object.assign(tl, {
|
|||
loading: false,
|
||||
followers: [],
|
||||
friends: [],
|
||||
flushMarker: 0,
|
||||
userId
|
||||
}))
|
||||
userId: 0,
|
||||
flushMarker: 0
|
||||
})
|
||||
|
||||
export const defaultState = {
|
||||
allStatuses: [],
|
||||
|
@ -33,13 +33,14 @@ export const defaultState = {
|
|||
favorites: new Set(),
|
||||
error: false,
|
||||
timelines: {
|
||||
mentions: emptyTl({ type: 'mentions' }),
|
||||
public: emptyTl({ type: 'public' }),
|
||||
user: emptyTl({ type: 'user' }), // TODO: switch to unregistered
|
||||
publicAndExternal: emptyTl({ type: 'publicAndExternal' }),
|
||||
friends: emptyTl({ type: 'friends' }),
|
||||
tag: emptyTl({ type: 'tag' }),
|
||||
dms: emptyTl({ type: 'dms' })
|
||||
mentions: emptyTl(),
|
||||
public: emptyTl(),
|
||||
user: emptyTl(),
|
||||
favorites: emptyTl(),
|
||||
publicAndExternal: emptyTl(),
|
||||
friends: emptyTl(),
|
||||
tag: emptyTl(),
|
||||
dms: emptyTl()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
|
|||
|
||||
const allStatuses = state.allStatuses
|
||||
const allStatusesObject = state.allStatusesObject
|
||||
const timelineObject = typeof timeline === 'object' ? timeline : state.timelines[timeline]
|
||||
const timelineObject = state.timelines[timeline]
|
||||
|
||||
const maxNew = statuses.length > 0 ? maxBy(statuses, 'id').id : 0
|
||||
const older = timeline && maxNew < timelineObject.maxId
|
||||
|
@ -297,7 +298,7 @@ export const mutations = {
|
|||
addNewStatuses,
|
||||
addNewNotifications,
|
||||
showNewStatuses (state, { timeline }) {
|
||||
const oldTimeline = (typeof timeline === 'object' ? timeline : state.timelines[timeline])
|
||||
const oldTimeline = (state.timelines[timeline])
|
||||
|
||||
oldTimeline.newStatusCount = 0
|
||||
oldTimeline.visibleStatuses = slice(oldTimeline.statuses, 0, 50)
|
||||
|
@ -306,8 +307,7 @@ export const mutations = {
|
|||
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
|
||||
},
|
||||
clearTimeline (state, { timeline }) {
|
||||
const timelineObject = typeof timeline === 'object' ? timeline : state.timelines[timeline]
|
||||
emptyTl(timelineObject, timeline.userId)
|
||||
state.timelines[timeline] = emptyTl()
|
||||
},
|
||||
setFavorited (state, { status, value }) {
|
||||
const newStatus = state.allStatusesObject[status.id]
|
||||
|
@ -327,8 +327,7 @@ export const mutations = {
|
|||
newStatus.deleted = true
|
||||
},
|
||||
setLoading (state, { timeline, value }) {
|
||||
const timelineObject = typeof timeline === 'object' ? timeline : state.timelines[timeline]
|
||||
timelineObject.loading = value
|
||||
state.timelines[timeline].loading = value
|
||||
},
|
||||
setNsfw (state, { id, nsfw }) {
|
||||
const newStatus = state.allStatusesObject[id]
|
||||
|
@ -349,8 +348,7 @@ export const mutations = {
|
|||
})
|
||||
},
|
||||
queueFlush (state, { timeline, id }) {
|
||||
const timelineObject = typeof timeline === 'object' ? timeline : state.timelines[timeline]
|
||||
timelineObject.flushMarker = id
|
||||
state.timelines[timeline].flushMarker = id
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue