fix(admin-web): invalidate workspace cache after every AI-points-consuming call
Top-nav quota chip (会员到期 / 生成文章 / AI 点数) only refreshes when its query is invalidated. Several mutations and stream-based flows that debit points or article quota on the server were not invalidating it, so users had to refresh the page to see updated balances. - TemplateWizardView: invalidate `['workspace']` inside `endAssistTask()`, covering analyze / title / outline assist tasks in one place. - FreeCreateView: invalidate after `articlesApi.create` success. - GenerateTaskDrawer: add `['workspace']` to the instant-generate `Promise.all` alongside the existing `articles` / `instantTasks` keys. - KolPromptEditor: invalidate in the `finally` of both `runAiAssistStream` (generate) and `generateSelectionAiPreview` (optimize) so abort / error paths also refresh. - ArticleEditorCanvas: bring in `useQueryClient` and invalidate in the selection-optimize stream `finally`. Together with the existing invalidations in TemplateWizard.generate, ImitationGenerate, KolGenerate, and article-regenerate, every quota- debiting call site now feeds the cache refresh. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -173,6 +173,7 @@ const instantGenerateMutation = useMutation({
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ['articles'] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['instantTasks'] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['workspace'] }),
|
||||
])
|
||||
},
|
||||
onError: (error) => message.error(formatError(error)),
|
||||
|
||||
Reference in New Issue
Block a user