()
| 43 | } |
| 44 | |
| 45 | const loadFile = async () => { |
| 46 | try { |
| 47 | setLoading(true); |
| 48 | if (type === "skills") { |
| 49 | const data = await getSkill(name); |
| 50 | setContent(data.content); |
| 51 | const match = data.content.match(/<description>([\s\S]*?)<\/description>/); |
| 52 | setDescription(data.description || (match ? match[1].trim() : "")); |
| 53 | setCurrentName(name); |
| 54 | } else if (type === "commands") { |
| 55 | const data = await getCommand(name); |
| 56 | setContent(data.template); |
| 57 | setCurrentName(name); |
| 58 | } else { |
| 59 | const data = await getPlugin(name); |
| 60 | setContent(data.content); |
| 61 | setCurrentName(name); |
| 62 | } |
| 63 | } catch { |
| 64 | toast.error("Failed to load file"); |
| 65 | router.back(); |
| 66 | } finally { |
| 67 | setLoading(false); |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | loadFile(); |
| 72 | }, [type, name, isNew, router]); |
no test coverage detected