Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions resources/js/composables/useFollowAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export function useFollowAccount() {
}
})

// Invalidate following feed so it includes new follows
queryClient.invalidateQueries({ queryKey: ['following-feed'] })
// Optionally update user's following count
queryClient.invalidateQueries({ queryKey: ['user-profile'] })
}
Expand Down Expand Up @@ -56,6 +58,8 @@ export function useFollowAccount() {
}
})

// Invalidate following feed so it excludes unfollowed accounts
queryClient.invalidateQueries({ queryKey: ['following-feed'] })
// Optionally update user's following count
queryClient.invalidateQueries({ queryKey: ['user-profile'] })
}
Expand Down
6 changes: 6 additions & 0 deletions resources/js/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { nextTick } from 'vue'
import axios from '@/plugins/axios'
import { useAuthStore } from '@/stores/auth'
import { useAlertModal } from '@/composables/useAlertModal.js'
import { useQueryClient } from '@tanstack/vue-query'
const { confirmModal } = useAlertModal()

export const useProfileStore = defineStore('profile', {
Expand Down Expand Up @@ -284,6 +285,11 @@ export const useProfileStore = defineStore('profile', {
this.followerCount = res.follower_count
await nextTick()
await this.getProfileState(this.id)
try {
const queryClient = useQueryClient()
queryClient.invalidateQueries({ queryKey: ['following-feed'] })
} catch (e) {}

if (!prevState && this.isFollowingRequestPending) {
this.pollFollowRequestState().catch((err) => {
console.error('Error polling follow request state:', err)
Expand Down
9 changes: 9 additions & 0 deletions resources/js/stores/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'
import axios from '~/plugins/axios'
import { ref } from 'vue'
import { useQueryClient } from '@tanstack/vue-query'

export const useSearchStore = defineStore('search', () => {
const searchQuery = ref('')
Expand Down Expand Up @@ -185,6 +186,10 @@ export const useSearchStore = defineStore('search', () => {
user.is_following = true
user.follower_count = (user.follower_count || 0) + 1
}
try {
const queryClient = useQueryClient()
queryClient.invalidateQueries({ queryKey: ['following-feed'] })
} catch (e) {}

return { success: true }
} catch (err) {
Expand All @@ -206,6 +211,10 @@ export const useSearchStore = defineStore('search', () => {
user.is_following = false
user.follower_count = Math.max(0, (user.follower_count || 0) - 1)
}
try {
const queryClient = useQueryClient()
queryClient.invalidateQueries({ queryKey: ['following-feed'] })
} catch (e) {}

return { success: true }
} catch (err) {
Expand Down
9 changes: 9 additions & 0 deletions resources/js/stores/video.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineStore } from 'pinia'
import axios from '~/plugins/axios'
import { useQueryClient } from '@tanstack/vue-query'

export const useVideoStore = defineStore('video', {
state: () => ({
Expand Down Expand Up @@ -204,6 +205,10 @@ export const useVideoStore = defineStore('video', {
const axiosInstance = axios.getAxiosInstance()
try {
const res = await axiosInstance.post(`/api/v1/account/follow/${userId}`)
try {
const queryClient = useQueryClient()
queryClient.invalidateQueries({ queryKey: ['following-feed'] })
} catch (e) {}
return res.data
} catch (error) {
console.error('Error following user:', error)
Expand All @@ -215,6 +220,10 @@ export const useVideoStore = defineStore('video', {
const axiosInstance = axios.getAxiosInstance()
try {
const res = await axiosInstance.post(`/api/v1/account/unfollow/${userId}`)
try {
const queryClient = useQueryClient()
queryClient.invalidateQueries({ queryKey: ['following-feed'] })
} catch (e) {}
return res.data
} catch (error) {
console.error('Error unfollowing user:', error)
Expand Down