forked from AkkomaGang/akkoma-fe
fixed few-posts TLs when streaming is enabled
This commit is contained in:
parent
48bef143d8
commit
9a8bc245a6
7 changed files with 37 additions and 11 deletions
|
@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Fixed local dev mode having non-functional websockets in some cases
|
- Fixed local dev mode having non-functional websockets in some cases
|
||||||
- Show notices for websocket events (errors, abnormal closures, reconnections)
|
- Show notices for websocket events (errors, abnormal closures, reconnections)
|
||||||
- Fix not being able to re-enable websocket until page refresh
|
- Fix not being able to re-enable websocket until page refresh
|
||||||
|
- Fix annoying issue where timeline might have few posts when streaming is enabled
|
||||||
|
|
||||||
## [2.2.2] - 2020-12-22
|
## [2.2.2] - 2020-12-22
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -35,11 +35,6 @@ const Notifications = {
|
||||||
seenToDisplayCount: DEFAULT_SEEN_TO_DISPLAY_COUNT
|
seenToDisplayCount: DEFAULT_SEEN_TO_DISPLAY_COUNT
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
|
||||||
const store = this.$store
|
|
||||||
const credentials = store.state.users.currentUser.credentials
|
|
||||||
notificationsFetcher.fetchAndUpdate({ store, credentials })
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
mainClass () {
|
mainClass () {
|
||||||
return this.minimalMode ? '' : 'panel panel-default'
|
return this.minimalMode ? '' : 'panel panel-default'
|
||||||
|
|
|
@ -188,6 +188,13 @@ const api = {
|
||||||
if (!fetcher) return
|
if (!fetcher) return
|
||||||
store.commit('removeFetcher', { fetcherName: timeline, fetcher })
|
store.commit('removeFetcher', { fetcherName: timeline, fetcher })
|
||||||
},
|
},
|
||||||
|
fetchTimeline (store, timeline, { ...rest }) {
|
||||||
|
store.state.backendInteractor.fetchTimeline({
|
||||||
|
store,
|
||||||
|
timeline,
|
||||||
|
...rest
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
startFetchingNotifications (store) {
|
startFetchingNotifications (store) {
|
||||||
|
@ -200,6 +207,12 @@ const api = {
|
||||||
if (!fetcher) return
|
if (!fetcher) return
|
||||||
store.commit('removeFetcher', { fetcherName: 'notifications', fetcher })
|
store.commit('removeFetcher', { fetcherName: 'notifications', fetcher })
|
||||||
},
|
},
|
||||||
|
fetchNotifications (store, { ...rest }) {
|
||||||
|
store.state.backendInteractor.fetchNotifications({
|
||||||
|
store,
|
||||||
|
...rest
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// Follow requests
|
// Follow requests
|
||||||
startFetchingFollowRequests (store) {
|
startFetchingFollowRequests (store) {
|
||||||
|
|
|
@ -547,6 +547,8 @@ const users = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (store.getters.mergedConfig.useStreamingApi) {
|
if (store.getters.mergedConfig.useStreamingApi) {
|
||||||
|
store.dispatch('fetchTimeline', 'friends', { since: null })
|
||||||
|
store.dispatch('fetchNotifications', { since: null })
|
||||||
store.dispatch('enableMastoSockets').catch((error) => {
|
store.dispatch('enableMastoSockets').catch((error) => {
|
||||||
console.error('Failed initializing MastoAPI Streaming socket', error)
|
console.error('Failed initializing MastoAPI Streaming socket', error)
|
||||||
startPolling()
|
startPolling()
|
||||||
|
|
|
@ -1,17 +1,25 @@
|
||||||
import apiService, { getMastodonSocketURI, ProcessedWS } from '../api/api.service.js'
|
import apiService, { getMastodonSocketURI, ProcessedWS } from '../api/api.service.js'
|
||||||
import timelineFetcherService from '../timeline_fetcher/timeline_fetcher.service.js'
|
import timelineFetcher from '../timeline_fetcher/timeline_fetcher.service.js'
|
||||||
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
|
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
|
||||||
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
||||||
|
|
||||||
const backendInteractorService = credentials => ({
|
const backendInteractorService = credentials => ({
|
||||||
startFetchingTimeline ({ timeline, store, userId = false, tag }) {
|
startFetchingTimeline ({ timeline, store, userId = false, tag }) {
|
||||||
return timelineFetcherService.startFetching({ timeline, store, credentials, userId, tag })
|
return timelineFetcher.startFetching({ timeline, store, credentials, userId, tag })
|
||||||
|
},
|
||||||
|
|
||||||
|
fetchTimeline (args) {
|
||||||
|
return timelineFetcher.fetchAndUpdate({ ...args, credentials })
|
||||||
},
|
},
|
||||||
|
|
||||||
startFetchingNotifications ({ store }) {
|
startFetchingNotifications ({ store }) {
|
||||||
return notificationsFetcher.startFetching({ store, credentials })
|
return notificationsFetcher.startFetching({ store, credentials })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fetchNotifications (args) {
|
||||||
|
return notificationsFetcher.fetchAndUpdate({ ...args, credentials })
|
||||||
|
},
|
||||||
|
|
||||||
startFetchingFollowRequests ({ store }) {
|
startFetchingFollowRequests ({ store }) {
|
||||||
return followRequestFetcher.startFetching({ store, credentials })
|
return followRequestFetcher.startFetching({ store, credentials })
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@ const update = ({ store, notifications, older }) => {
|
||||||
store.dispatch('addNewNotifications', { notifications, older })
|
store.dispatch('addNewNotifications', { notifications, older })
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchAndUpdate = ({ store, credentials, older = false }) => {
|
const fetchAndUpdate = ({ store, credentials, older = false, since }) => {
|
||||||
const args = { credentials }
|
const args = { credentials }
|
||||||
const { getters } = store
|
const { getters } = store
|
||||||
const rootState = store.rootState || store.state
|
const rootState = store.rootState || store.state
|
||||||
|
@ -22,8 +22,10 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => {
|
||||||
return fetchNotifications({ store, args, older })
|
return fetchNotifications({ store, args, older })
|
||||||
} else {
|
} else {
|
||||||
// fetch new notifications
|
// fetch new notifications
|
||||||
if (timelineData.maxId !== Number.POSITIVE_INFINITY) {
|
if (since === undefined && timelineData.maxId !== Number.POSITIVE_INFINITY) {
|
||||||
args['since'] = timelineData.maxId
|
args['since'] = timelineData.maxId
|
||||||
|
} else if (since !== null) {
|
||||||
|
args['since'] = since
|
||||||
}
|
}
|
||||||
const result = fetchNotifications({ store, args, older })
|
const result = fetchNotifications({ store, args, older })
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ const fetchAndUpdate = ({
|
||||||
showImmediately = false,
|
showImmediately = false,
|
||||||
userId = false,
|
userId = false,
|
||||||
tag = false,
|
tag = false,
|
||||||
until
|
until,
|
||||||
|
since
|
||||||
}) => {
|
}) => {
|
||||||
const args = { timeline, credentials }
|
const args = { timeline, credentials }
|
||||||
const rootState = store.rootState || store.state
|
const rootState = store.rootState || store.state
|
||||||
|
@ -35,7 +36,11 @@ const fetchAndUpdate = ({
|
||||||
if (older) {
|
if (older) {
|
||||||
args['until'] = until || timelineData.minId
|
args['until'] = until || timelineData.minId
|
||||||
} else {
|
} else {
|
||||||
|
if (since === undefined) {
|
||||||
args['since'] = timelineData.maxId
|
args['since'] = timelineData.maxId
|
||||||
|
} else if (since !== null) {
|
||||||
|
args['since'] = since
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args['userId'] = userId
|
args['userId'] = userId
|
||||||
|
|
Loading…
Reference in a new issue