cleared mods and modpack handler

This commit is contained in:
knoxfighter 2020-08-25 04:53:21 +02:00
parent 251d937b4d
commit ec16db3983
4 changed files with 485 additions and 413 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,8 @@ const Mods = () => {
const fetchInstalledMods = () => {
modsResource.installed()
.then(res => {
if (res.success) {
setInstalledMods(res.data || []);
if (res) {
setInstalledMods(res || []);
}
});
};

View File

@ -19,7 +19,7 @@ const Mod = ({refreshInstalledMods, mod, factorioVersion}) => {
const toggleMod = async modName => {
const res = await modsResource.toggle(modName);
if (res.success) {
if (res) {
refreshInstalledMods();
}
}
@ -47,8 +47,8 @@ const Mod = ({refreshInstalledMods, mod, factorioVersion}) => {
useEffect(() => {
(async () => {
const {success, data} = await modsResource.details(mod.name)
if (success) {
const {data} = await modsResource.details(mod.name)
if (data) {
//get newest COMPATIBLE release
let newestRelease;
data.releases.forEach(release => {

View File

@ -6,44 +6,30 @@ const mods = {
return response.data;
},
toggle: async modName => {
let data = new FormData();
data.set('modName', modName);
const response = await client.post('/api/mods/toggle', data);
const response = await client.post('/api/mods/toggle', JSON.stringify({modName}));
return response.data;
},
delete: async modName => {
const data = new FormData();
data.set('modName', modName);
const response = await client.post('/api/mods/delete', data);
const response = await client.post('/api/mods/delete', JSON.stringify({modName}));
return response.data;
},
details: async modName => {
const data = new FormData();
data.set('modId', modName);
const response = await client.post('/api/mods/details', data);
const response = await client.post('/api/mods/details', JSON.stringify({modName}));
return {
success: response.data.success,
data: JSON.parse(response.data.data)
data: JSON.parse(response.data)
};
},
update: async (modName, downloadUrl, fileName) => {
const data = new FormData();
data.set('modName', modName);
data.set('downloadUrl', downloadUrl);
data.set('filename', fileName);
const data = {
modName: modName,
downloadUrl: downloadUrl,
fileName: fileName,
}
const response = await client.post('/api/mods/update', data, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
const response = await client.post('/api/mods/update', data)
return response.data;
}
}
export default mods;