forked from Shinonome/dots-hyprland
booru: fix messed up responses
This commit is contained in:
@@ -72,7 +72,7 @@ class BooruService extends Service {
|
|||||||
this._mode = value;
|
this._mode = value;
|
||||||
this._baseUrl = APISERVICES[this._mode].endpoint;
|
this._baseUrl = APISERVICES[this._mode].endpoint;
|
||||||
}
|
}
|
||||||
get providerName () {
|
get providerName() {
|
||||||
return APISERVICES[this._mode].name;
|
return APISERVICES[this._mode].name;
|
||||||
}
|
}
|
||||||
get queries() { return this._queries }
|
get queries() { return this._queries }
|
||||||
@@ -88,7 +88,7 @@ class BooruService extends Service {
|
|||||||
for (let i = 0; i < userArgs.length; i++) {
|
for (let i = 0; i < userArgs.length; i++) {
|
||||||
const thisArg = userArgs[i].trim();
|
const thisArg = userArgs[i].trim();
|
||||||
if (thisArg.length == 0 || thisArg == '.' || thisArg.includes('*')) continue;
|
if (thisArg.length == 0 || thisArg == '.' || thisArg.includes('*')) continue;
|
||||||
else if(!isNaN(thisArg)) page = parseInt(thisArg);
|
else if (!isNaN(thisArg)) page = parseInt(thisArg);
|
||||||
else taglist.push(thisArg);
|
else taglist.push(thisArg);
|
||||||
}
|
}
|
||||||
const newMessageId = this._queries.length;
|
const newMessageId = this._queries.length;
|
||||||
@@ -113,6 +113,7 @@ class BooruService extends Service {
|
|||||||
};
|
};
|
||||||
let status = 0;
|
let status = 0;
|
||||||
// console.log(`${APISERVICES[this._mode].endpoint}?${paramString}`);
|
// console.log(`${APISERVICES[this._mode].endpoint}?${paramString}`);
|
||||||
|
|
||||||
Utils.fetch(`${APISERVICES[this._mode].endpoint}?${paramString}`, options)
|
Utils.fetch(`${APISERVICES[this._mode].endpoint}?${paramString}`, options)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
status = result.status;
|
status = result.status;
|
||||||
@@ -122,7 +123,7 @@ class BooruService extends Service {
|
|||||||
// console.log(dataString);
|
// console.log(dataString);
|
||||||
const parsedData = JSON.parse(dataString);
|
const parsedData = JSON.parse(dataString);
|
||||||
// console.log(parsedData)
|
// console.log(parsedData)
|
||||||
this._responses.push(parsedData.map(obj => {
|
this._responses[newMessageId] = parsedData.map(obj => {
|
||||||
return {
|
return {
|
||||||
aspect_ratio: obj.width / obj.height,
|
aspect_ratio: obj.width / obj.height,
|
||||||
id: obj.id,
|
id: obj.id,
|
||||||
@@ -140,7 +141,7 @@ class BooruService extends Service {
|
|||||||
file_height: obj.file_height,
|
file_height: obj.file_height,
|
||||||
source: getWorkingImageSauce(obj.source),
|
source: getWorkingImageSauce(obj.source),
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
this.emit('updateResponse', newMessageId);
|
this.emit('updateResponse', newMessageId);
|
||||||
})
|
})
|
||||||
.catch(print);
|
.catch(print);
|
||||||
|
|||||||
Reference in New Issue
Block a user