P3 fixes
This commit is contained in:
parent
3b856e94da
commit
5788d3e8ec
10 changed files with 38 additions and 33 deletions
|
|
@ -36,7 +36,7 @@ const notificationsFetcher = (credentials) => {
|
|||
const notifications = response.data
|
||||
if (older && notifications.length === 0) bottomedOut.value = true
|
||||
|
||||
useNotificationsStore().addNewNotifications(response)
|
||||
useNotificationsStore().addNewNotifications(response, older)
|
||||
} catch (error) {
|
||||
if (
|
||||
error.statusCode === 400 &&
|
||||
|
|
@ -78,7 +78,7 @@ const notificationsFetcher = (credentials) => {
|
|||
|
||||
args.timeline = 'notifications'
|
||||
if (older) {
|
||||
if (timelineData.minId !== Number.POSITIVE_INFINITY) {
|
||||
if (timelineData.minId !== '') {
|
||||
args.maxId = timelineData.minId
|
||||
}
|
||||
return await fetchNotifications({ args, older })
|
||||
|
|
@ -86,7 +86,7 @@ const notificationsFetcher = (credentials) => {
|
|||
// fetch new notifications
|
||||
if (
|
||||
sinceId === undefined &&
|
||||
timelineData.maxId !== Number.POSITIVE_INFINITY
|
||||
timelineData.maxId !== ''
|
||||
) {
|
||||
args.sinceId = timelineData.maxId
|
||||
} else if (sinceId !== null) {
|
||||
|
|
|
|||
|
|
@ -134,14 +134,7 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
1001, // Going away
|
||||
])
|
||||
const { code } = closeEvent.original
|
||||
if (intendedCodes.has(code)) {
|
||||
this.pushGlobalNotice({
|
||||
level: 'success',
|
||||
messageKey: 'timeline.socket_closed',
|
||||
messageArgs: [code],
|
||||
timeout: 5000,
|
||||
})
|
||||
} else {
|
||||
if (!intendedCodes.has(code)) {
|
||||
this.pushGlobalNotice({
|
||||
level: 'error',
|
||||
messageKey: 'timeline.socket_broke',
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ export const useStreamingStore = defineStore('streaming', {
|
|||
},
|
||||
stopSocket() {
|
||||
this.socket.close()
|
||||
this.socket = null
|
||||
this.state = WSConnectionStatus.CLOSED
|
||||
this.retrying = false
|
||||
this.retryMultiplier = 1
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ export const ARGUMENT_MAP = {
|
|||
user: 'userId',
|
||||
userPinned: 'userId',
|
||||
media: 'userId',
|
||||
favorites: 'userId',
|
||||
}
|
||||
|
||||
const TIMELINES = new Set([
|
||||
|
|
@ -180,7 +181,7 @@ export const useTimelinesStore = defineStore('timelines', {
|
|||
timeline.socket.handlers
|
||||
timeline.socket.et.removeEventListener('open', openHandler)
|
||||
timeline.socket.et.removeEventListener('close', closeHandler)
|
||||
timeline.socket.et.removeEventListener('message', messageHandler)
|
||||
timeline.socket.et.removeEventListener('update', messageHandler)
|
||||
}
|
||||
|
||||
this[timelineName] = emptyTl(timelineName)
|
||||
|
|
@ -267,8 +268,6 @@ export const useTimelinesStore = defineStore('timelines', {
|
|||
if (statuses.length === 0) return
|
||||
const timeline = this[timelineName]
|
||||
|
||||
this.populateRepeats(timeline, repeats)
|
||||
|
||||
// This makes sure that user timeline won't get data meant for other
|
||||
// user. I.e. opening different user profiles makes request which could
|
||||
// return data late after user already viewing different user profile
|
||||
|
|
@ -279,6 +278,8 @@ export const useTimelinesStore = defineStore('timelines', {
|
|||
return
|
||||
}
|
||||
|
||||
this.populateRepeats(timeline, repeats)
|
||||
|
||||
const filtered = statuses.filter((id) => !timeline.statusIds.has(id))
|
||||
if (older) {
|
||||
timeline.order.push(...filtered)
|
||||
|
|
|
|||
|
|
@ -276,15 +276,21 @@ export const useUsersStore = defineStore('users', {
|
|||
|
||||
const result = await promise
|
||||
|
||||
if (result) {
|
||||
const { id, screen_name } = result
|
||||
try {
|
||||
if (result) {
|
||||
const { id, screen_name } = result
|
||||
|
||||
// Save promise for future use
|
||||
this.fetchesIds.set(id, promise)
|
||||
this.fetchesNames.set(screen_name, promise)
|
||||
return this.users.get(id)
|
||||
} else {
|
||||
return null
|
||||
// Save promise for future use
|
||||
this.fetchesIds.set(id, promise)
|
||||
this.fetchesNames.set(screen_name, promise)
|
||||
return this.users.get(id)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`Failed fetching user ${identifier}`, e)
|
||||
map.delete(identifier)
|
||||
throw e
|
||||
}
|
||||
},
|
||||
async fetchUser(id) {
|
||||
|
|
@ -518,7 +524,7 @@ export const useUsersStore = defineStore('users', {
|
|||
|
||||
/// Mute
|
||||
muteUser(id, expiresIn = 0) {
|
||||
const predictedRelationship = this.relationships[id] || { id }
|
||||
const predictedRelationship = this.relationships.get(id) || { id }
|
||||
predictedRelationship.muting = true
|
||||
this.updateUserRelationships({
|
||||
optimism: true,
|
||||
|
|
@ -537,7 +543,7 @@ export const useUsersStore = defineStore('users', {
|
|||
return Promise.all(data.map((d) => this.muteUser(d)))
|
||||
},
|
||||
unmuteUser(id) {
|
||||
const predictedRelationship = this.relationships[id] || { id }
|
||||
const predictedRelationship = this.relationships.get(id) || { id }
|
||||
predictedRelationship.muting = false
|
||||
this.updateUserRelationships({
|
||||
optimism: true,
|
||||
|
|
@ -554,7 +560,7 @@ export const useUsersStore = defineStore('users', {
|
|||
|
||||
/// Block
|
||||
blockUser(id, expiresIn = 0) {
|
||||
const predictedRelationship = this.relationships[id] || { id }
|
||||
const predictedRelationship = this.relationships.get(id) || { id }
|
||||
this.updateUserRelationships({
|
||||
optimism: true,
|
||||
data: [predictedRelationship],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue