mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-03 18:57:43 +01:00
Merge pull request #3915 from h3poteto/feat/reduce-limit
Reduce initial timeline length
This commit is contained in:
commit
6975666f6b
@ -73,7 +73,7 @@ export const ACTION_TYPES = {
|
||||
const actions: ActionTree<BookmarksState, RootState> = {
|
||||
[ACTION_TYPES.FETCH_BOOKMARKS]: async ({ commit, rootState }, account: LocalAccount): Promise<Array<Entity.Status>> => {
|
||||
const client = generator(rootState.TimelineSpace.sns, account.baseURL, account.accessToken, rootState.App.userAgent)
|
||||
const res = await client.getBookmarks({ limit: 40 })
|
||||
const res = await client.getBookmarks({ limit: 20 })
|
||||
commit(MUTATION_TYPES.UPDATE_BOOKMARKS, res.data)
|
||||
// Parse link header
|
||||
try {
|
||||
@ -103,7 +103,7 @@ const actions: ActionTree<BookmarksState, RootState> = {
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.App.userAgent
|
||||
)
|
||||
const res = await client.getFavourites({ max_id: state.maxId, limit: 40 }).finally(() => {
|
||||
const res = await client.getFavourites({ max_id: state.maxId, limit: 20 }).finally(() => {
|
||||
commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, false)
|
||||
})
|
||||
commit(MUTATION_TYPES.INSERT_BOOKMARKS, res.data)
|
||||
|
@ -46,7 +46,7 @@ const mutations: MutationTree<DirectMessagesState> = {
|
||||
state.timeline = state.timeline.concat(messages)
|
||||
},
|
||||
[MUTATION_TYPES.ARCHIVE_TIMELINE]: state => {
|
||||
state.timeline = state.timeline.slice(0, 40)
|
||||
state.timeline = state.timeline.slice(0, 20)
|
||||
},
|
||||
[MUTATION_TYPES.CLEAR_TIMELINE]: state => {
|
||||
state.timeline = []
|
||||
@ -93,7 +93,7 @@ const actions: ActionTree<DirectMessagesState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
try {
|
||||
const res = await client.getConversationTimeline({ limit: 40 })
|
||||
const res = await client.getConversationTimeline({ limit: 20 })
|
||||
const statuses: Array<Entity.Status> = res.data.map(con => con.last_status!)
|
||||
commit(MUTATION_TYPES.UPDATE_TIMELINE, statuses)
|
||||
return statuses
|
||||
@ -118,7 +118,7 @@ const actions: ActionTree<DirectMessagesState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
return client
|
||||
.getConversationTimeline({ max_id: lastStatus.id, limit: 40 })
|
||||
.getConversationTimeline({ max_id: lastStatus.id, limit: 20 })
|
||||
.then(res => {
|
||||
const statuses: Array<Entity.Status> = res.data.map(con => con.last_status!)
|
||||
commit(MUTATION_TYPES.INSERT_TIMELINE, statuses)
|
||||
|
@ -73,7 +73,7 @@ export const ACTION_TYPES = {
|
||||
const actions: ActionTree<FavouritesState, RootState> = {
|
||||
fetchFavourites: async ({ commit, rootState }, account: LocalAccount): Promise<Array<Entity.Status>> => {
|
||||
const client = generator(rootState.TimelineSpace.sns, account.baseURL, account.accessToken, rootState.App.userAgent)
|
||||
const res = await client.getFavourites({ limit: 40 })
|
||||
const res = await client.getFavourites({ limit: 20 })
|
||||
commit(MUTATION_TYPES.UPDATE_FAVOURITES, res.data)
|
||||
// Parse link header
|
||||
try {
|
||||
@ -103,7 +103,7 @@ const actions: ActionTree<FavouritesState, RootState> = {
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.App.userAgent
|
||||
)
|
||||
const res = await client.getFavourites({ max_id: state.maxId, limit: 40 }).finally(() => {
|
||||
const res = await client.getFavourites({ max_id: state.maxId, limit: 20 }).finally(() => {
|
||||
commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, false)
|
||||
})
|
||||
commit(MUTATION_TYPES.INSERT_FAVOURITES, res.data)
|
||||
|
@ -54,7 +54,7 @@ const mutations: MutationTree<TagState> = {
|
||||
state.timeline = state.timeline.concat(messages)
|
||||
},
|
||||
[MUTATION_TYPES.ARCHIVE_TIMELINE]: state => {
|
||||
state.timeline = state.timeline.slice(0, 40)
|
||||
state.timeline = state.timeline.slice(0, 20)
|
||||
},
|
||||
[MUTATION_TYPES.CLEAR_TIMELINE]: state => {
|
||||
state.timeline = []
|
||||
@ -109,7 +109,7 @@ const actions: ActionTree<TagState, RootState> = {
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.App.userAgent
|
||||
)
|
||||
const res = await client.getTagTimeline(encodeURIComponent(tag), { limit: 40 })
|
||||
const res = await client.getTagTimeline(encodeURIComponent(tag), { limit: 20 })
|
||||
commit(MUTATION_TYPES.UPDATE_TIMELINE, res.data)
|
||||
return res.data
|
||||
},
|
||||
@ -159,7 +159,7 @@ const actions: ActionTree<TagState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
return client
|
||||
.getTagTimeline(loadPosition.tag, { max_id: loadPosition.status.id, limit: 40 })
|
||||
.getTagTimeline(loadPosition.tag, { max_id: loadPosition.status.id, limit: 20 })
|
||||
.then(res => {
|
||||
commit(MUTATION_TYPES.INSERT_TIMELINE, res.data)
|
||||
return res.data
|
||||
|
@ -58,7 +58,7 @@ const mutations: MutationTree<HomeState> = {
|
||||
state.timeline = state.timeline.concat(messages)
|
||||
},
|
||||
[MUTATION_TYPES.ARCHIVE_TIMELINE]: state => {
|
||||
state.timeline = state.timeline.slice(0, 40)
|
||||
state.timeline = state.timeline.slice(0, 20)
|
||||
},
|
||||
[MUTATION_TYPES.CLEAR_TIMELINE]: state => {
|
||||
state.timeline = []
|
||||
@ -146,16 +146,16 @@ const actions: ActionTree<HomeState, RootState> = {
|
||||
since_id: lastReadStatus.id,
|
||||
// We don't need to fill this field in the first fetcing.
|
||||
// Because in most cases there is no new statuses at the first fetching.
|
||||
// After new statuses are received, if the number of unread statuses is more than 40, max_id is not necessary.
|
||||
// After new statuses are received, if the number of unread statuses is more than 20, max_id is not necessary.
|
||||
// We can fill max_id when calling fetchTimelineSince.
|
||||
// If the number of unread statuses is less than 40, max_id is necessary, but it is enough to reject duplicated statuses.
|
||||
// If the number of unread statuses is less than 20, max_id is necessary, but it is enough to reject duplicated statuses.
|
||||
// So we do it in mutation.
|
||||
max_id: null,
|
||||
id: 'loading-card',
|
||||
uri: 'loading-card'
|
||||
}
|
||||
|
||||
const res = await client.getHomeTimeline({ limit: 40, max_id: lastReadStatus.id })
|
||||
const res = await client.getHomeTimeline({ limit: 20, max_id: lastReadStatus.id })
|
||||
// Make sure whether new statuses exist or not.
|
||||
const nextResponse = await client.getHomeTimeline({ limit: 1, min_id: lastReadStatus.id })
|
||||
if (nextResponse.data.length > 0) {
|
||||
@ -166,7 +166,7 @@ const actions: ActionTree<HomeState, RootState> = {
|
||||
commit(MUTATION_TYPES.UPDATE_TIMELINE, timeline)
|
||||
return res.data
|
||||
} else {
|
||||
const res = await client.getHomeTimeline({ limit: 40 })
|
||||
const res = await client.getHomeTimeline({ limit: 20 })
|
||||
commit(MUTATION_TYPES.UPDATE_TIMELINE, res.data)
|
||||
return res.data
|
||||
}
|
||||
@ -186,7 +186,7 @@ const actions: ActionTree<HomeState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
return client
|
||||
.getHomeTimeline({ max_id: lastStatus.id, limit: 40 })
|
||||
.getHomeTimeline({ max_id: lastStatus.id, limit: 20 })
|
||||
.then(res => {
|
||||
commit(MUTATION_TYPES.INSERT_TIMELINE, res.data)
|
||||
return res.data
|
||||
@ -222,7 +222,7 @@ const actions: ActionTree<HomeState, RootState> = {
|
||||
// Also, we can get statuses which are older than max_id and newer than min_id.
|
||||
// If the number of statuses exceeds the limit, it truncates newer statuses.
|
||||
// That means, the status immediately before max_id is not included in the response.
|
||||
let params = { min_id: since_id, limit: 40 }
|
||||
let params = { min_id: since_id, limit: 20 }
|
||||
if (maxID !== null) {
|
||||
params = Object.assign({}, params, {
|
||||
max_id: maxID
|
||||
@ -230,7 +230,7 @@ const actions: ActionTree<HomeState, RootState> = {
|
||||
}
|
||||
|
||||
const res = await client.getHomeTimeline(params)
|
||||
if (res.data.length >= 40) {
|
||||
if (res.data.length >= 20) {
|
||||
const card: LoadingCard = {
|
||||
type: 'middle-load',
|
||||
since_id: res.data[0].id,
|
||||
|
@ -54,7 +54,7 @@ const mutations: MutationTree<ShowState> = {
|
||||
state.timeline = state.timeline.concat(messages)
|
||||
},
|
||||
[MUTATION_TYPES.ARCHIVE_TIMELINE]: state => {
|
||||
state.timeline = state.timeline.slice(0, 40)
|
||||
state.timeline = state.timeline.slice(0, 20)
|
||||
},
|
||||
[MUTATION_TYPES.CLEAR_TIMELINE]: state => {
|
||||
state.timeline = []
|
||||
@ -109,7 +109,7 @@ const actions: ActionTree<ShowState, RootState> = {
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.App.userAgent
|
||||
)
|
||||
const res = await client.getListTimeline(listID, { limit: 40 })
|
||||
const res = await client.getListTimeline(listID, { limit: 20 })
|
||||
commit(MUTATION_TYPES.UPDATE_TIMELINE, res.data)
|
||||
return res.data
|
||||
},
|
||||
@ -159,7 +159,7 @@ const actions: ActionTree<ShowState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
return client
|
||||
.getListTimeline(loadPosition.list_id, { max_id: loadPosition.status.id, limit: 40 })
|
||||
.getListTimeline(loadPosition.list_id, { max_id: loadPosition.status.id, limit: 20 })
|
||||
.then(res => {
|
||||
commit(MUTATION_TYPES.INSERT_TIMELINE, res.data)
|
||||
return res.data
|
||||
|
@ -105,7 +105,7 @@ const actions: ActionTree<LocalState, RootState> = {
|
||||
)
|
||||
|
||||
try {
|
||||
const res = await client.getLocalTimeline({ limit: 40 })
|
||||
const res = await client.getLocalTimeline({ limit: 20 })
|
||||
commit(MUTATION_TYPES.UPDATE_TIMELINE, res.data)
|
||||
return res.data
|
||||
} catch (err) {
|
||||
@ -129,7 +129,7 @@ const actions: ActionTree<LocalState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
return client
|
||||
.getLocalTimeline({ max_id: lastStatus.id, limit: 40 })
|
||||
.getLocalTimeline({ max_id: lastStatus.id, limit: 20 })
|
||||
.then(res => {
|
||||
commit(MUTATION_TYPES.INSERT_TIMELINE, res.data)
|
||||
return res.data
|
||||
|
@ -61,7 +61,7 @@ const mutations: MutationTree<MentionsState> = {
|
||||
state.mentions = state.mentions.concat(messages)
|
||||
},
|
||||
[MUTATION_TYPES.ARCHIVE_MENTIONS]: state => {
|
||||
state.mentions = state.mentions.slice(0, 40)
|
||||
state.mentions = state.mentions.slice(0, 30)
|
||||
},
|
||||
[MUTATION_TYPES.CLEAR_MENTIONS]: state => {
|
||||
state.mentions = []
|
||||
|
@ -50,7 +50,7 @@ const mutations: MutationTree<PublicState> = {
|
||||
state.timeline = state.timeline.concat(messages)
|
||||
},
|
||||
[MUTATION_TYPES.ARCHIVE_TIMELINE]: state => {
|
||||
state.timeline = state.timeline.slice(0, 40)
|
||||
state.timeline = state.timeline.slice(0, 20)
|
||||
},
|
||||
[MUTATION_TYPES.CLEAR_TIMELINE]: state => {
|
||||
state.timeline = []
|
||||
@ -104,7 +104,7 @@ const actions: ActionTree<PublicState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
try {
|
||||
const res = await client.getPublicTimeline({ limit: 40 })
|
||||
const res = await client.getPublicTimeline({ limit: 20 })
|
||||
commit(MUTATION_TYPES.UPDATE_TIMELINE, res.data)
|
||||
return res.data
|
||||
} catch (err) {
|
||||
@ -128,7 +128,7 @@ const actions: ActionTree<PublicState, RootState> = {
|
||||
rootState.App.userAgent
|
||||
)
|
||||
return client
|
||||
.getPublicTimeline({ max_id: lastStatus.id, limit: 40 })
|
||||
.getPublicTimeline({ max_id: lastStatus.id, limit: 20 })
|
||||
.then(res => {
|
||||
commit(MUTATION_TYPES.INSERT_TIMELINE, res.data)
|
||||
return res.data
|
||||
|
Loading…
x
Reference in New Issue
Block a user