Refactor api.account to api.accounts + Added action.discard to quizs

This commit is contained in:
Niko 2022-02-27 13:44:32 +01:00
parent 8e1f2af662
commit 034963b258
7 changed files with 27 additions and 15 deletions

View File

@ -124,6 +124,10 @@ img.avatar {
top: -2px; top: -2px;
color: #fff; color: #fff;
} }
.component.button.form > .center {
position: relative;
left: -.4em;
}
a.button { a.button {
text-decoration: none; text-decoration: none;
color: initial; color: initial;

View File

@ -1,5 +1,5 @@
var api = { var api = {
account: { accounts: {
block: function(url, cback) { block: function(url, cback) {
cback = cback || function() {}; cback = cback || function() {};
http.post(`/api/v1/accounts/block?url=${url}`, {}, function(json) { http.post(`/api/v1/accounts/block?url=${url}`, {}, function(json) {

View File

@ -181,7 +181,7 @@ app.pages.meet = {
const current = app.pages.meet.dataCurrent(); const current = app.pages.meet.dataCurrent();
if (current === undefined || current === null) if (current === undefined || current === null)
return app.toast.error(s('app.error.unknown_error')); return app.toast.error(s('app.error.unknown_error'));
api.account.block(current.account.url, function(json) { api.accounts.block(current.account.url, function(json) {
setTimeout(function() { setTimeout(function() {
for (var i = app.pages.meet.data.length-1; i >= 0; i--) for (var i = app.pages.meet.data.length-1; i >= 0; i--)
if (app.pages.meet.data[i].account.url === current.account.url) if (app.pages.meet.data[i].account.url === current.account.url)

View File

@ -149,7 +149,12 @@ app.pages.quiz = {
}, },
actions: { actions: {
discard: function() { discard: function() {
console.log('DISCARD'); const dt = page().data;
if (dt.from === undefined)
return; // TODO: add unknown error?
api.accounts.block(dt.from.url, function(json) {
setTimeout(function(){ exit() }, app.toast.DEFAULT_MILLIS);
});
}, },
send: function() { send: function() {
console.log('SEND'); console.log('SEND');

View File

@ -55,22 +55,21 @@
<br> <br>
<div class="flex width-max"> <div class="flex width-max">
<div class="flex center width-max" style="max-width: 32em"> <div class="flex center width-max" style="max-width: 32em">
<div class="flex width-max" style="padding: 0 .4em"> <div class="width-max" style="padding: 0 1.2em">
<a class="component button form rounder2 card-item flex width-max" <div class="component button form rounder card-item"
style="background-color: $clr_button_yellow"
onclick="page().actions.discard()">
<span class="center">
<i class="fa fa-close fa-fw"></i>{s:app.discard}
</span>
</a>
<div style="max-width: 1.5em" class="width-max"></div>
<a class="component button form rounder2 card-item flex width-max"
style="background-color: $clr_button_green" style="background-color: $clr_button_green"
onclick="page().actions.send()"> onclick="page().actions.send()">
<span class="center"> <span class="center">
<i class="fa fa-send fa-fw"></i>{s:app.send} <i class="fa fa-send fa-fw"></i>{s:app.send_quiz}
</span> </span>
</a> </div>
<div class="component button form rounder card-item"
style="background-color: $clr_button_yellow"
onclick="page().actions.discard()">
<span class="center">
<i class="fa fa-close fa-fw"></i>{s:app.not_interested}
</span>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -27,6 +27,8 @@ $strings = [
'questions' =< 'questions', 'questions' =< 'questions',
'send' => 'Send', 'send' => 'Send',
'discard' => 'Discard', 'discard' => 'Discard',
'send_quiz' => 'Send Quiz!',
'not_interested' => 'No longer interested',
'nav' => [ 'nav' => [
'meet' => 'Meet', 'meet' => 'Meet',
'crushes' => 'Your crushes', 'crushes' => 'Your crushes',

View File

@ -27,6 +27,8 @@ $strings = [
'questions' => 'preguntas', 'questions' => 'preguntas',
'send' => 'Enviar', 'send' => 'Enviar',
'discard' => 'Descartar', 'discard' => 'Descartar',
'send_quiz' => '¡Enviar Quiz!',
'not_interested' => 'Ya no me interesa',
'nav' => [ 'nav' => [
'meet' => 'Conoce', 'meet' => 'Conoce',
'crushes' => 'Tus crush', 'crushes' => 'Tus crush',