refs #574 Fix duplicated message when receive unread statuses

This commit is contained in:
AkiraFukushima 2021-12-26 23:15:31 +09:00
parent baf69b813b
commit 98e36a1c78
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
2 changed files with 24 additions and 2 deletions

View File

@ -206,8 +206,24 @@ const actions: ActionTree<HomeState, RootState> = {
if (cardIndex > 0) {
maxID = state.timeline[cardIndex - 1].id
}
// Memo: What happens when we specify both of max_id and min_id?
// What is the difference between max_id & since_id and max_id & min_id?
// The max_id & since_id:
// We can get statuses which are older than max_id and newer than since_id.
// If the number of statuses exceeds the limit, it truncates older statuses.
// That means, the status immediately after since_id is not included in the response.
// The max_id & min_id:
// 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 }
if (maxID !== null) {
params = Object.assign({}, params, {
max_id: maxID
})
}
const res = await client.getHomeTimeline({ min_id: since_id, limit: 40 })
const res = await client.getHomeTimeline(params)
if (res.data.length >= 40) {
const card: LoadingCard = {
type: 'middle-load',

View File

@ -197,8 +197,14 @@ const actions: ActionTree<NotificationsState, RootState> = {
if (cardIndex > 0) {
maxID = state.notifications[cardIndex - 1].id
}
let params = { min_id: since_id, limit: 30 }
if (maxID !== null) {
params = Object.assign({}, params, {
max_id: maxID
})
}
const res = await client.getNotifications({ min_id: since_id, limit: 30 })
const res = await client.getNotifications(params)
if (res.data.length >= 30) {
const card: LoadingCard = {
type: 'middle-load',