mirror of
https://github.com/maunium/stickerpicker.git
synced 2025-08-28 02:41:48 +02:00
Remove thumbnail_url
This commit is contained in:
@@ -43,37 +43,63 @@ export function sendSticker(content){
|
|||||||
api.sendSticker(data);
|
api.sendSticker(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sendGIF(content){
|
/*
|
||||||
// just print out content, should be URL
|
*export function sendGIF(content){
|
||||||
|
* // just print out content, should be URL
|
||||||
|
* console.log("Content:"+content.url);
|
||||||
|
* return new Promise((resolve, reject) => {
|
||||||
|
* const xhr = new XMLHttpRequest();
|
||||||
|
* xhr.open('GET', content.url, true);
|
||||||
|
* xhr.onreadystatechange = function() {
|
||||||
|
* if (xhr.readyState === 4) {
|
||||||
|
* if (xhr.status === 200) {
|
||||||
|
* const responseData = xhr.responseText;
|
||||||
|
* // Call uploadFile with response data
|
||||||
|
* api.uploadFile(responseData)
|
||||||
|
* .then(result => {
|
||||||
|
* console.log("Here's the result:"+result.content_uri);
|
||||||
|
* // mess around with the content object, then send it as sticker
|
||||||
|
* content.url = result.content_uri;
|
||||||
|
* sendSticker(content);
|
||||||
|
* resolve(result);
|
||||||
|
* })
|
||||||
|
* .catch(error => {
|
||||||
|
* reject(error);
|
||||||
|
* });
|
||||||
|
* } else {
|
||||||
|
* reject(new Error('Failed to fetch data')); // Reject the outer promise if fetching data fails
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
* xhr.send();
|
||||||
|
* });
|
||||||
|
*}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export async function sendGIF(content){
|
||||||
|
// just print content, since it's a custom type with URL
|
||||||
console.log("Content:"+content.url);
|
console.log("Content:"+content.url);
|
||||||
return new Promise((resolve, reject) => {
|
// use fetch because I'm on IE
|
||||||
const xhr = new XMLHttpRequest();
|
const lol = await fetch(content.url);
|
||||||
xhr.open('GET', content.url, true);
|
const uri_file = await lol.blob();
|
||||||
xhr.onreadystatechange = function() {
|
// call uploadFile with this
|
||||||
if (xhr.readyState === 4) {
|
var result = await api.uploadFile(uri_file)
|
||||||
if (xhr.status === 200) {
|
console.log("Got URI:"+result.content_uri);
|
||||||
const responseData = xhr.responseText;
|
content.url = result.content_uri;
|
||||||
// Call uploadFile with response data
|
// get thumbnail
|
||||||
api.uploadFile(responseData)
|
//const thumb_uri = await fetch(content.info.thumbnail_url)
|
||||||
.then(result => {
|
//const thumb_file = await thumb_uri.blob();
|
||||||
console.log("Here's the result:"+result.content_uri);
|
//result = await api.uploadFile(thumb_file)
|
||||||
// mess around with the content object, then send it as sticker
|
//console.log("Thumb URI:"+result.content_uri);
|
||||||
content.url = result.content_uri;
|
//content.info.thumbnail_url = result.content_uri;
|
||||||
sendSticker(content);
|
// actually, just delete the thumbnail
|
||||||
resolve(result);
|
delete content.info.thumbnail_url;
|
||||||
})
|
// finally, send it as sticker
|
||||||
.catch(error => {
|
sendSticker(content);
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
reject(new Error('Failed to fetch data')); // Reject the outer promise if fetching data fails
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*let widgetId = null
|
*let widgetId = null
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user