Page MenuHomePhorge

No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
index 59dd73fce6..19c14b9d80 100644
--- a/src/services/notifications_fetcher/notifications_fetcher.service.js
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -1,73 +1,73 @@
import apiService from '../api/api.service.js'
const update = ({store, notifications, older}) => {
store.dispatch('setNotificationsError', { value: false })
store.dispatch('addNewNotifications', { notifications, older })
}
const fetchAndUpdate = ({store, credentials, older = false}) => {
const args = { credentials }
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.notifications
args['timeline'] = 'notifications'
if (older) {
if (timelineData.minId !== Number.POSITIVE_INFINITY) {
args['until'] = timelineData.minId
}
return fetchNotifications({ store, args, older })
} else {
// fetch new notifications
if (timelineData.maxId !== Number.POSITIVE_INFINITY) {
args['since'] = timelineData.maxId
}
const result = fetchNotifications({ store, args, older })
// load unread notifications repeatedly to provide consistency between browser tabs
const notifications = timelineData.data
const unread = notifications.filter(n => !n.seen).map(n => n.id)
if (unread.length) {
args['since'] = Math.min(...unread)
fetchNotifications({ store, args, older })
}
return result
}
}
const fetchNotifications = ({ store, args, older }) => {
return apiService.fetchTimeline(args)
.then((notifications) => {
update({ store, notifications, older })
return notifications
}, () => store.dispatch('setNotificationsError', { value: true }))
.catch(() => store.dispatch('setNotificationsError', { value: true }))
}
const startFetching = ({credentials, store}) => {
let fetchRequest = fetchAndUpdate({ credentials, store })
const boundFetchAndUpdate = () => {
fetchRequest.stop()
fetchRequest = fetchAndUpdate({ credentials, store })
}
// Initially there's set flag to silence all desktop notifications so
// that there won't spam of them when user just opened up the FE we
// reset that flag after a while to show new notifications once again.
setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000)
const fetcher = setInterval(boundFetchAndUpdate, 10000)
const stop = () => {
window.clearInterval(fetcher)
- fetchRequest.stop()
+ // fetchRequest.stop()
}
return {
stop
}
}
const notificationsFetcher = {
fetchAndUpdate,
startFetching
}
export default notificationsFetcher
diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js
index 48606d2b89..2ddfa798ee 100644
--- a/src/services/timeline_fetcher/timeline_fetcher.service.js
+++ b/src/services/timeline_fetcher/timeline_fetcher.service.js
@@ -1,82 +1,74 @@
import { camelCase } from 'lodash'
import apiService from '../api/api.service.js'
const update = ({store, statuses, timeline, showImmediately, userId}) => {
const ccTimeline = camelCase(timeline)
store.dispatch('setError', { value: false })
store.dispatch('addNewStatuses', {
timeline: ccTimeline,
userId,
statuses,
showImmediately
})
}
const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until}) => {
- let stopFetcher = false
+ // let stopFetcher = false
const args = { timeline, credentials }
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
const hideMutedPosts = typeof rootState.config.hideMutedPosts === 'undefined'
? rootState.instance.hideMutedPosts
: rootState.config.hideMutedPosts
if (older) {
args['until'] = until || timelineData.minId
} else {
args['since'] = timelineData.maxId
}
args['userId'] = userId
args['tag'] = tag
args['withMuted'] = !hideMutedPosts
const numStatusesBeforeFetch = timelineData.statuses.length
- apiService.fetchTimeline(args)
+ return apiService.fetchTimeline(args)
.then((statuses) => {
if (stopFetcher) { return false }
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
}
update({store, statuses, timeline, showImmediately, userId})
return statuses
}, () => store.dispatch('setError', { value: true }))
-
- const stop = () => {
- stopFetcher = true
- }
-
- return {
- stop
- }
}
const startFetching = ({timeline = 'friends', credentials, store, userId = false, tag = false}) => {
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
const showImmediately = timelineData.visibleStatuses.length === 0
timelineData.userId = userId
let fetchRequest = fetchAndUpdate({timeline, credentials, store, showImmediately, userId, tag})
const boundFetchAndUpdate = () => {
fetchRequest.stop()
fetchRequest = fetchAndUpdate({ timeline, credentials, store, userId, tag })
}
const fetcher = setInterval(boundFetchAndUpdate, 10000)
const stop = () => {
window.clearInterval(fetcher)
- fetchRequest.stop()
+ // fetchRequest.stop()
}
return {
stop
}
}
const timelineFetcher = {
fetchAndUpdate,
startFetching
}
export default timelineFetcher

File Metadata

Mime Type
text/x-diff
Expires
Mon, Aug 10, 4:23 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1724869
Default Alt Text
(5 KB)

Event Timeline