From 034963b25872fc272d6432a67d7d8be190b64df4 Mon Sep 17 00:00:00 2001 From: Niko Date: Sun, 27 Feb 2022 13:44:32 +0100 Subject: [PATCH] Refactor api.account to api.accounts + Added action.discard to quizs --- web/src/app/css/app.css | 4 ++++ web/src/app/js/api.js | 2 +- web/src/app/js/pages/meet.js | 2 +- web/src/app/js/pages/quiz.js | 7 ++++++- web/src/app/js/templates/quiz/index.html | 23 +++++++++++------------ web/src/config/lang/en.php | 2 ++ web/src/config/lang/es.php | 2 ++ 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/web/src/app/css/app.css b/web/src/app/css/app.css index 75be6f1..82052be 100644 --- a/web/src/app/css/app.css +++ b/web/src/app/css/app.css @@ -124,6 +124,10 @@ img.avatar { top: -2px; color: #fff; } +.component.button.form > .center { + position: relative; + left: -.4em; +} a.button { text-decoration: none; color: initial; diff --git a/web/src/app/js/api.js b/web/src/app/js/api.js index 8fe5417..3f6806f 100644 --- a/web/src/app/js/api.js +++ b/web/src/app/js/api.js @@ -1,5 +1,5 @@ var api = { - account: { + accounts: { block: function(url, cback) { cback = cback || function() {}; http.post(`/api/v1/accounts/block?url=${url}`, {}, function(json) { diff --git a/web/src/app/js/pages/meet.js b/web/src/app/js/pages/meet.js index 3d0b764..f6a2048 100644 --- a/web/src/app/js/pages/meet.js +++ b/web/src/app/js/pages/meet.js @@ -181,7 +181,7 @@ app.pages.meet = { const current = app.pages.meet.dataCurrent(); if (current === undefined || current === null) 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() { for (var i = app.pages.meet.data.length-1; i >= 0; i--) if (app.pages.meet.data[i].account.url === current.account.url) diff --git a/web/src/app/js/pages/quiz.js b/web/src/app/js/pages/quiz.js index c2a461d..78511e8 100644 --- a/web/src/app/js/pages/quiz.js +++ b/web/src/app/js/pages/quiz.js @@ -149,7 +149,12 @@ app.pages.quiz = { }, actions: { 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() { console.log('SEND'); diff --git a/web/src/app/js/templates/quiz/index.html b/web/src/app/js/templates/quiz/index.html index 92689fc..c3559b6 100644 --- a/web/src/app/js/templates/quiz/index.html +++ b/web/src/app/js/templates/quiz/index.html @@ -55,22 +55,21 @@
diff --git a/web/src/config/lang/en.php b/web/src/config/lang/en.php index c4b1dd7..aa6fa3d 100644 --- a/web/src/config/lang/en.php +++ b/web/src/config/lang/en.php @@ -27,6 +27,8 @@ $strings = [ 'questions' =< 'questions', 'send' => 'Send', 'discard' => 'Discard', + 'send_quiz' => 'Send Quiz!', + 'not_interested' => 'No longer interested', 'nav' => [ 'meet' => 'Meet', 'crushes' => 'Your crushes', diff --git a/web/src/config/lang/es.php b/web/src/config/lang/es.php index b3397bf..79180f8 100644 --- a/web/src/config/lang/es.php +++ b/web/src/config/lang/es.php @@ -27,6 +27,8 @@ $strings = [ 'questions' => 'preguntas', 'send' => 'Enviar', 'discard' => 'Descartar', + 'send_quiz' => '¡Enviar Quiz!', + 'not_interested' => 'Ya no me interesa', 'nav' => [ 'meet' => 'Conoce', 'crushes' => 'Tus crush',