From 9529520bcd06d9b11c37a9152ce947535394a1a3 Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 2 Mar 2022 02:11:16 +0100 Subject: [PATCH] String refactoring on /app + added discard confirm in pages.meet --- web/src/app/js/pages/meet.js | 9 +++++++-- web/src/app/js/pages/quiz.js | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/web/src/app/js/pages/meet.js b/web/src/app/js/pages/meet.js index f6a2048..a20bb58 100644 --- a/web/src/app/js/pages/meet.js +++ b/web/src/app/js/pages/meet.js @@ -61,7 +61,7 @@ app.pages.meet = { if (item.account.props.gender === undefined) item.account.props.gender = 'unspecified'; if (item.account.props.place === undefined) - item.account.props.place = app.strings.app.the_fediverse; + item.account.props.place = s('app.the_fediverse'); if (item.account.props.pcolors === undefined) item.account.props.pcolors = {}; @@ -176,11 +176,16 @@ app.pages.meet = { } }); }, - discard: function() { + discard: async function() { document.activeElement.blur(); const current = app.pages.meet.dataCurrent(); if (current === undefined || current === null) return app.toast.error(s('app.error.unknown_error')); + + if (typeof current.quiz_id !== 'string' && + !await app.toast.warnConfirm(s('app.confirm.crush_discard'))) + return false; + api.accounts.block(current.account.url, function(json) { setTimeout(function() { for (var i = app.pages.meet.data.length-1; i >= 0; i--) diff --git a/web/src/app/js/pages/quiz.js b/web/src/app/js/pages/quiz.js index 10be435..3c4b807 100644 --- a/web/src/app/js/pages/quiz.js +++ b/web/src/app/js/pages/quiz.js @@ -44,7 +44,7 @@ app.pages.quiz = { if (json.from.props.gender === undefined) json.from.props.gender = 'unspecified'; if (json.from.props.place === undefined) - json.from.props.place = app.strings.app.the_fediverse; + json.from.props.place = s('app.the_fediverse'); const container = document.getElementById('app-container'); container.innerHTML = app.template.fill(json, app.template.get('quiz.index'), function(k,v) { @@ -158,7 +158,7 @@ app.pages.quiz = { }, actions: { discard: async function() { - if (!await app.toast.warnConfirm(app.strings.app.confirm.crush_discard)) + if (!await app.toast.warnConfirm(s('app.confirm.crush_discard'))) return false; const dt = page().data; if (dt.from === undefined) @@ -168,7 +168,7 @@ app.pages.quiz = { }); }, send: async function() { - if (!await app.toast.infoConfirm(app.strings.app.confirm.crush_send_quiz)) + if (!await app.toast.infoConfirm(s('app.confirm.crush_send_quiz'))) return false; const form = document.querySelector('form#quiz'); var data = { quiz_id: page().data.id }; @@ -183,7 +183,7 @@ app.pages.quiz = { if (json.error !== undefined) app.toast.error(app.strings.app.error[json.error]); else if (json.result === 1) { - app.toast.info(app.strings.app.ok.quiz_sent); + app.toast.info(s('app.ok.quiz_sent_wait')); setTimeout(function(){ exit() }, app.toast.DEFAULT_MILLIS); } });