修正按讚、儀表板彙總 BUG
This commit is contained in:
@@ -424,8 +424,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
if (!user) return false
|
||||
|
||||
try {
|
||||
const isCurrentlyLiked = userLikes[user.id]?.includes(appId) || false
|
||||
|
||||
const response = await fetch(`/api/apps/${appId}/interactions`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -440,13 +438,14 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
if (data.success) {
|
||||
// 更新應用統計數據
|
||||
setAppStats(prev => ({
|
||||
...prev,
|
||||
[appId]: data.data
|
||||
}))
|
||||
|
||||
// 更新用戶的按讚狀態
|
||||
const newLikedState = !isCurrentlyLiked
|
||||
// 使用 API 返回的按讚狀態更新本地狀態
|
||||
const newLikedState = data.data.userLiked
|
||||
setUserLikes(prev => ({
|
||||
...prev,
|
||||
[user.id]: newLikedState
|
||||
|
Reference in New Issue
Block a user