fix: add $autoCancel:false to games API calls
GamesLibrary auto-cancellation error was caused by missing $autoCancel:false on all games.ts PocketBase SDK calls. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+19
-13
@@ -15,7 +15,8 @@ export async function getGroupGames(groupId: string, options?: {
|
||||
|
||||
const result = await pb.collection('games').getList(page, limit, {
|
||||
filter,
|
||||
sort: '-created'
|
||||
sort: '-created',
|
||||
$autoCancel: false
|
||||
})
|
||||
return { items: result.items as unknown as Game[], total: result.totalItems }
|
||||
}
|
||||
@@ -33,12 +34,12 @@ export async function addGame(groupId: string, data: {
|
||||
group: groupId,
|
||||
addedBy: user?.id,
|
||||
popularCount: 0
|
||||
})
|
||||
}, { $autoCancel: false })
|
||||
}
|
||||
|
||||
// 删除游戏
|
||||
export async function deleteGame(gameId: string) {
|
||||
return pb.collection('games').delete(gameId)
|
||||
return pb.collection('games').delete(gameId, { $autoCancel: false })
|
||||
}
|
||||
|
||||
// 导入游戏(批量添加)
|
||||
@@ -64,7 +65,8 @@ export async function importGames(groupId: string, games: Array<{
|
||||
export async function exportGames(groupId: string): Promise<Game[]> {
|
||||
const result = await pb.collection('games').getFullList({
|
||||
filter: `group="${groupId}"`,
|
||||
sort: '-created'
|
||||
sort: '-created',
|
||||
$autoCancel: false
|
||||
})
|
||||
return result as unknown as Game[]
|
||||
}
|
||||
@@ -75,17 +77,18 @@ export async function toggleFavorite(gameId: string): Promise<boolean> {
|
||||
if (!user) throw new Error('未登录')
|
||||
|
||||
const existing = await pb.collection('game_favorites').getList(1, 1, {
|
||||
filter: `game="${gameId}" && user="${user.id}"`
|
||||
filter: `game="${gameId}" && user="${user.id}"`,
|
||||
$autoCancel: false
|
||||
})
|
||||
|
||||
if (existing.items.length > 0) {
|
||||
await pb.collection('game_favorites').delete(existing.items[0].id)
|
||||
await pb.collection('game_favorites').delete(existing.items[0].id, { $autoCancel: false })
|
||||
return false
|
||||
} else {
|
||||
await pb.collection('game_favorites').create({
|
||||
game: gameId,
|
||||
user: user.id
|
||||
})
|
||||
}, { $autoCancel: false })
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -96,7 +99,8 @@ export async function isFavorite(gameId: string): Promise<boolean> {
|
||||
if (!user) return false
|
||||
|
||||
const result = await pb.collection('game_favorites').getList(1, 1, {
|
||||
filter: `game="${gameId}" && user="${user.id}"`
|
||||
filter: `game="${gameId}" && user="${user.id}"`,
|
||||
$autoCancel: false
|
||||
})
|
||||
return result.items.length > 0
|
||||
}
|
||||
@@ -111,7 +115,7 @@ export async function addComment(gameId: string, content: string, rating?: numbe
|
||||
author: user.id,
|
||||
content,
|
||||
rating
|
||||
})
|
||||
}, { $autoCancel: false })
|
||||
}
|
||||
|
||||
// 获取游戏评论
|
||||
@@ -119,7 +123,8 @@ export async function getGameComments(gameId: string): Promise<GameComment[]> {
|
||||
const result = await pb.collection('game_comments').getList(1, 50, {
|
||||
filter: `game="${gameId}"`,
|
||||
sort: '-created',
|
||||
expand: 'author'
|
||||
expand: 'author',
|
||||
$autoCancel: false
|
||||
})
|
||||
return result.items as unknown as GameComment[]
|
||||
}
|
||||
@@ -137,7 +142,8 @@ export async function searchGames(query: string, groupId?: string, limit = 20):
|
||||
|
||||
const result = await pb.collection('games').getList(1, limit, {
|
||||
filter,
|
||||
sort: '-popularCount'
|
||||
sort: '-popularCount',
|
||||
$autoCancel: false
|
||||
})
|
||||
return result.items as unknown as Game[]
|
||||
}
|
||||
@@ -147,9 +153,9 @@ export async function getPopularGames(limit = 10): Promise<Game[]> {
|
||||
const user = pb.authStore.model
|
||||
if (!user) return []
|
||||
|
||||
// 获取用户所在群组的游戏
|
||||
const result = await pb.collection('games').getList(1, limit, {
|
||||
sort: '-popularCount'
|
||||
sort: '-popularCount',
|
||||
$autoCancel: false
|
||||
})
|
||||
return result.items as unknown as Game[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user