mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-07 06:07:18 +08:00
fix: skills count not displaying when adding (#1295)
* fix: skills count not displaying when adding * fix: get real skill count by awaiting discovery after adding repo The previous approach computed count before discovery, so it was always 0. Now we await refetchDiscoverable() after the mutation, then filter the fresh skills list to get the actual count for the toast message. Also reverts the SkillRepo.count field — keep the interface clean since count is a transient UI concern, not a data model property. --------- Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
@@ -164,10 +164,20 @@ export const SkillsPage = forwardRef<SkillsPageHandle, SkillsPageProps>(
|
||||
const handleAddRepo = async (repo: SkillRepo) => {
|
||||
try {
|
||||
await addRepoMutation.mutateAsync(repo);
|
||||
// Await discovery so we can report the real count
|
||||
const { data: freshSkills } = await refetchDiscoverable();
|
||||
const count =
|
||||
freshSkills?.filter(
|
||||
(s) =>
|
||||
s.repoOwner === repo.owner &&
|
||||
s.repoName === repo.name &&
|
||||
(s.repoBranch || "main") === (repo.branch || "main"),
|
||||
).length ?? 0;
|
||||
toast.success(
|
||||
t("skills.repo.addSuccess", {
|
||||
owner: repo.owner,
|
||||
name: repo.name,
|
||||
count,
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user