Add discard implementation on pages.meet actions

This commit is contained in:
Niko 2022-02-18 17:52:34 +01:00
parent ddce1560bf
commit 7ce1522234
1 changed files with 24 additions and 4 deletions

View File

@ -136,13 +136,33 @@ app.pages.meet = {
document.activeElement.blur(); document.activeElement.blur();
const current = app.pages.meet.dataCurrent(); const current = app.pages.meet.dataCurrent();
if (current === null) if (current === null)
return console.error('TODO: add-to-toast: notify user an unknown error') return console.error('TODO: add-to-toast: notify user an unknown error');
http.post(`/api/v1/accounts/follow?url=${current.account.url}`, {}, function(json) { http.post(`/api/v1/accounts/follow?url=${current.account.url}`, {}, function(json) {
if (json === undefined) return;
if (json.error !== undefined) if (json.error !== undefined)
console.error('TODO: add-to-toast: notify user an unknown error') console.error('TODO: add-to-toast: notify user an unknown error');
else if (json.result !== undefined && json.result === 1) else if (json.result !== undefined && json.result === 1)
console.log('TODO: add-to-toast: crush was marked succesfully!') console.log('TODO: add-to-toast: crush was marked succesfully!');
}) });
},
discard: function() {
document.activeElement.blur();
const current = app.pages.meet.dataCurrent();
if (current === null)
return console.error('TODO: add-to-toast: notify user an unknown error');
http.post(`/api/v1/accounts/block?url=${current.account.url}`, {}, function(json) {
if (json === undefined) return;
if (json.error !== undefined)
console.error('TODO: add-to-toast: notify user an unknown error');
else if (json.result !== undefined && json.result === 1) {
console.log('TODO: add-to-toast: person was blocked succesfully!');
for (var i = app.pages.meet.data.length-1; i >= 0; i--)
if (app.pages.meet.data[i].account.url === current.account.url)
app.pages.meet.data.splice(i, 1);
app.pages.meet.carousel.set(0);
app.pages.meet.paint();
}
});
}, },
}, },
exit: function() { exit: function() {