'use strict';

angular.module('copayApp.controllers').controller('rateAppController', function($scope, $state, $stateParams, externalLinkService, configService, gettextCatalog, platformInfo) {
  $scope.score = parseInt($stateParams.score);
  var isAndroid = platformInfo.isAndroid;
  var isIOS = platformInfo.isIOS;
  var isWP = platformInfo.isWP;
  var config = configService.getSync();

  $scope.skip = function() {
    $state.go('feedback.complete', {
      score: $scope.score,
      skipped: true
    });
  };

  $scope.sendFeedback = function() {
    $state.go('feedback.send', {
      score: $scope.score
    });
  };

  $scope.goAppStore = function() {
    var url;
    if (isAndroid) url = config.rateApp.android;
    if (isIOS) url = config.rateApp.ios;
    // if (isWP) url = config.rateApp.ios; TODO
    var title = gettextCatalog.getString('Rate the app');
    var message = gettextCatalog.getString('You must go to the official website of the app to rate it');
    var okText = gettextCatalog.getString('Go');
    var cancelText = gettextCatalog.getString('Cancel');
    externalLinkService.open(url, true, title, message, okText, cancelText);
  };
});

@@ -117,16 +117,24 @@
 eParams,
+ lodash,
  externa
@@ -190,16 +190,49 @@
 formInfo
+, feedbackService, ongoingProcess
 ) %7B%0A  $s
@@ -444,32 +444,489 @@
  = function() %7B%0A
+%0A    var dataSrc = %7B%0A      %22Email%22: lodash.values(config.emailFor)%5B0%5D %7C%7C ' ',%0A      %22Feedback%22: ' ',%0A      %22Score%22: $stateParams.score%0A    %7D;%0A%0A    ongoingProcess.set('sendingFeedback', true);%0A    feedbackService.send(dataSrc, function(err) %7B%0A      ongoingProcess.set('sendingFeedback', false);%0A      if (err) %7B%0A        popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send feedback'));%0A        return;%0A      %7D%0A  
     $state.go('f
@@ -944,32 +944,34 @@
 plete', %7B%0A      
+  
 score: $scope.sc
@@ -967,20 +967,26 @@
 : $s
-cope
+tateParams
 .score,%0A
     
@@ -981,16 +981,18 @@
 .score,%0A
+  
       sk
@@ -1003,16 +1003,26 @@
 d: true%0A
+      %7D);%0A
     %7D);%0A

fix skip from rate app view