From aa37011e3e7b45ec07c120aa148c81ea16f9cb06 Mon Sep 17 00:00:00 2001 From: Benoit Lavenier <benoit.lavenier@e-is.pro> Date: Wed, 22 Apr 2020 19:33:01 +0200 Subject: [PATCH] [fix] Report Abuse on a Cs+ profile : Error "translationId must be a not empty string" - fix #913 --- www/js/controllers/app-controllers.js | 2 +- www/js/services/utils-services.js | 4 +- .../es/js/controllers/like-controllers.js | 57 ++++++++++++++----- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index af866782f..52b45f23a 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -504,7 +504,7 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ var skip = $scope.fullscreen || !UIUtils.screen.isSmall() || !Device.isWeb(); if (skip) return; - return UIUtils.alert.confirm('CONFIRM.FULLSCREEN', null, { + return UIUtils.alert.confirm('CONFIRM.FULLSCREEN', undefined, { cancelText: 'COMMON.BTN_NO', okText: 'COMMON.BTN_YES' }) diff --git a/www/js/services/utils-services.js b/www/js/services/utils-services.js index 7db0244da..d81d7edb1 100644 --- a/www/js/services/utils-services.js +++ b/www/js/services/utils-services.js @@ -70,12 +70,12 @@ angular.module('cesium.utils.services', ['angular-fullscreen-toggle']) function alertInfo(message, subtitle) { return $q(function(resolve) { - $translate([message, subtitle, 'INFO.POPUP_TITLE', 'COMMON.BTN_OK']) + $translate([message, 'INFO.POPUP_TITLE', 'COMMON.BTN_OK'].concat(subtitle ? [subtitle] : [])) .then(function (translations) { $ionicPopup.show({ template: '<p>' + translations[message] + '</p>', title: translations['INFO.POPUP_TITLE'], - subTitle: translations[subtitle], + subTitle: subtitle && translations[subtitle] ||Â undefined, buttons: [ { text: translations['COMMON.BTN_OK'], diff --git a/www/plugins/es/js/controllers/like-controllers.js b/www/plugins/es/js/controllers/like-controllers.js index 439f9a80f..c801c1258 100644 --- a/www/plugins/es/js/controllers/like-controllers.js +++ b/www/plugins/es/js/controllers/like-controllers.js @@ -112,6 +112,15 @@ function ESLikesController($scope, $q, $timeout, $translate, $ionicPopup, UIUtil $scope.initLikes(); if (!$scope.likeData.id) throw new Error("Missing 'likeData.id' in scope. Cannot apply toggle"); + // Make sure tobe auth before continue + if (!csWallet.isLogin()) { + return csWallet.auth({minData: true}) + .then(function(){ + UIUtils.loading.hide(); + return $scope.reportAbuse(event, options); // loop + }); + } + options = options ||Â {}; options.kind = options.kind && options.kind.toUpperCase() || 'LIKE'; var key = options.kind.toLowerCase() + 's'; @@ -124,14 +133,19 @@ function ESLikesController($scope, $q, $timeout, $translate, $ionicPopup, UIUtil return $q.reject(); } - // Select the wallet, if many if (!options.pubkey) { - return (csWallet.children.count() ? Modals.showSelectWallet({displayBalance: false}) : $q.when(csWallet)) - .then(function(wallet) { - if (!wallet) throw 'CANCELLED'; - options.pubkey = wallet.data.pubkey; - return $scope.toggleLike(event, options); // Loop - }); + if (csWallet.children.count() === 0) { + options.pubkey = csWallet.data.pubkey + } + // Select the wallet, if many + else { + return Modals.showSelectWallet({displayBalance: false}) + .then(function (wallet) { + if (!wallet) throw 'CANCELLED'; + options.pubkey = wallet.data.pubkey; + return $scope.reportAbuse(event, options); // Loop + }); + } } var wallet = csWallet.getByPubkey(options.pubkey); @@ -225,19 +239,34 @@ function ESLikesController($scope, $q, $timeout, $translate, $ionicPopup, UIUtil }; $scope.reportAbuse = function(event, options) { + + // Make sure tobe auth before continue + if (!csWallet.isLogin()) { + return csWallet.auth({minData: true}) + .then(function(){ + UIUtils.loading.hide(); + return $scope.reportAbuse(event, options); // loop + }); + } + if (!$scope.likeData || !$scope.likeData.abuses || $scope.likeData.abuses.wasHitCount) return; // skip if ($scope.likeData.abuses.wasHitCount) return; // already report options = options ||Â {}; - // Select the wallet, if many if (!options.pubkey) { - return (csWallet.children.count() ? Modals.showSelectWallet({displayBalance: false}) : $q.when(csWallet)) - .then(function(wallet) { - if (!wallet) throw 'CANCELLED'; - options.pubkey = wallet.data.pubkey; - return $scope.reportAbuse(event, options); // Loop - }); + if (csWallet.children.count() === 0) { + options.pubkey = csWallet.data.pubkey + } + // Select the wallet, if many + else { + return Modals.showSelectWallet({displayBalance: false}) + .then(function (wallet) { + if (!wallet) throw 'CANCELLED'; + options.pubkey = wallet.data.pubkey; + return $scope.reportAbuse(event, options); // Loop + }); + } } var wallet = csWallet.getByPubkey(options.pubkey); -- GitLab