Merge pull request #5013 from gabrielbazan7/fix/feedback
feedback feature refactor
This commit is contained in:
commit
da7bb1170b
17 changed files with 104 additions and 57 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('thanksController', function($scope, $stateParams, $timeout, $log, platformInfo, configService, storageService) {
|
||||
angular.module('copayApp.controllers').controller('completeController', function($scope, $stateParams, $timeout, $log, platformInfo, configService, storageService) {
|
||||
$scope.score = parseInt($stateParams.score);
|
||||
$scope.skipped = $stateParams.skipped == 'false' ? false : true;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
|
|
@ -31,7 +31,12 @@ angular.module('copayApp.controllers').controller('thanksController', function($
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
storageService.setRateCardFlag('true', function() {});
|
||||
storageService.getFeedbackInfo(function(error, info) {
|
||||
var feedbackInfo = JSON.parse(info);
|
||||
feedbackInfo.sent = true;
|
||||
storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() {});
|
||||
});
|
||||
|
||||
if (!$scope.isCordova) return;
|
||||
|
||||
window.plugins.socialsharing.available(function(isAvailable) {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('rateAppStoreController', function($scope, $state, $stateParams, externalLinkService, configService, gettextCatalog, platformInfo) {
|
||||
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;
|
||||
|
|
@ -8,14 +8,14 @@ angular.module('copayApp.controllers').controller('rateAppStoreController', func
|
|||
var config = configService.getSync();
|
||||
|
||||
$scope.skip = function() {
|
||||
$state.go('feedback.thanks', {
|
||||
$state.go('feedback.complete', {
|
||||
score: $scope.score,
|
||||
skipped: true
|
||||
});
|
||||
};
|
||||
|
||||
$scope.sendFeedback = function() {
|
||||
$state.go('feedback.sendFeedback', {
|
||||
$state.go('feedback.send', {
|
||||
score: $scope.score
|
||||
});
|
||||
};
|
||||
|
|
@ -10,11 +10,11 @@ angular.module('copayApp.controllers').controller('rateCardController', function
|
|||
$scope.rateModal.remove();
|
||||
}
|
||||
if ($scope.isCordova && $scope.score == 5) {
|
||||
$state.go('feedback.rateAppStore', {
|
||||
$state.go('feedback.rateApp', {
|
||||
score: $scope.score
|
||||
});
|
||||
} else {
|
||||
$state.go('feedback.sendFeedback', {
|
||||
$state.go('feedback.send', {
|
||||
score: $scope.score
|
||||
});
|
||||
}
|
||||
|
|
@ -49,8 +49,10 @@ angular.module('copayApp.controllers').controller('rateCardController', function
|
|||
$scope.rateModal.hide();
|
||||
$scope.rateModal.remove();
|
||||
} else {
|
||||
storageService.setRateCardFlag('true', function() {
|
||||
$scope.hideRateCard.value = true;
|
||||
storageService.getFeedbackInfo(function(error, info) {
|
||||
var feedbackInfo = JSON.parse(info);
|
||||
feedbackInfo.sent = true;
|
||||
storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() {});
|
||||
});
|
||||
}
|
||||
$timeout(function() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sendFeedbackController', function($scope, $state, $log, $stateParams, gettextCatalog, popupService, configService, lodash, feedbackService, ongoingProcess) {
|
||||
angular.module('copayApp.controllers').controller('sendController', function($scope, $state, $log, $stateParams, gettextCatalog, popupService, configService, lodash, feedbackService, ongoingProcess) {
|
||||
$scope.score = parseInt($stateParams.score);
|
||||
switch ($scope.score) {
|
||||
case 1:
|
||||
|
|
@ -42,7 +42,7 @@ angular.module('copayApp.controllers').controller('sendFeedbackController', func
|
|||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send feedback'));
|
||||
return;
|
||||
}
|
||||
$state.go('feedback.thanks', {
|
||||
$state.go('feedback.complete', {
|
||||
score: $stateParams.score,
|
||||
skipped: skip
|
||||
});
|
||||
|
|
@ -19,13 +19,7 @@ angular.module('copayApp.controllers').controller('welcomeController', function(
|
|||
$log.debug('Creating profile');
|
||||
profileService.createProfile(function(err) {
|
||||
if (err) $log.warn(err);
|
||||
setProfileCreationTime();
|
||||
});
|
||||
};
|
||||
|
||||
function setProfileCreationTime() {
|
||||
var now = moment().unix() * 1000 + 24 * 60 * 60 * 1000;
|
||||
storageService.setProfileCreationTime(now, function() {});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService, startupService, addressbookService) {
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService, startupService, addressbookService, feedbackService) {
|
||||
var wallet;
|
||||
var listeners = [];
|
||||
var notifications = [];
|
||||
|
|
@ -13,7 +13,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.isAndroid = platformInfo.isAndroid;
|
||||
$scope.isNW = platformInfo.isNW;
|
||||
$scope.hideRateCard = {};
|
||||
$scope.showRateCard = {};
|
||||
|
||||
$scope.$on("$ionicView.afterEnter", function() {
|
||||
startupService.ready();
|
||||
|
|
@ -37,13 +37,37 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
}
|
||||
|
||||
storageService.getProfileCreationTime(function(error, time) {
|
||||
var now = moment().unix() * 1000;
|
||||
storageService.getRateCardFlag(function(error, value) {
|
||||
$scope.hideRateCard.value = (value == 'true' || (time - now) > 0) ? true : false;
|
||||
});
|
||||
storageService.getFeedbackInfo(function(error, info) {
|
||||
if (!info) {
|
||||
initFeedBackInfo();
|
||||
} else {
|
||||
var feedbackInfo = JSON.parse(info);
|
||||
//Check if current version is greater than saved version
|
||||
var currentVersion = window.version;
|
||||
var savedVersion = feedbackInfo.version;
|
||||
var isVersionUpdated = feedbackService.isVersionUpdated(currentVersion, savedVersion);
|
||||
if (!isVersionUpdated) {
|
||||
initFeedBackInfo();
|
||||
return;
|
||||
}
|
||||
var now = moment().unix();
|
||||
var timeExceeded = (now - feedbackInfo.time) >= 24 * 60 * 60;
|
||||
$scope.showRateCard.value = timeExceeded && !feedbackInfo.sent;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function initFeedBackInfo() {
|
||||
var feedbackInfo = {};
|
||||
feedbackInfo.time = moment().unix();
|
||||
feedbackInfo.version = window.version;
|
||||
feedbackInfo.sent = false;
|
||||
storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() {
|
||||
$scope.showRateCard.value = false;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
|
|
|
|||
|
|
@ -731,30 +731,30 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
abstract: true,
|
||||
template: '<ion-nav-view name="feedback"></ion-nav-view>'
|
||||
})
|
||||
.state('feedback.sendFeedback', {
|
||||
url: '/sendFeedback/:score',
|
||||
.state('feedback.send', {
|
||||
url: '/send/:score',
|
||||
views: {
|
||||
'feedback': {
|
||||
controller: 'sendFeedbackController',
|
||||
templateUrl: 'views/feedback/sendFeedback.html'
|
||||
controller: 'sendController',
|
||||
templateUrl: 'views/feedback/send.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('feedback.thanks', {
|
||||
url: '/thanks/:score/:skipped',
|
||||
.state('feedback.complete', {
|
||||
url: '/complete/:score/:skipped',
|
||||
views: {
|
||||
'feedback': {
|
||||
controller: 'thanksController',
|
||||
templateUrl: 'views/feedback/thanks.html'
|
||||
controller: 'completeController',
|
||||
templateUrl: 'views/feedback/complete.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('feedback.rateAppStore', {
|
||||
url: '/rateAppStore/:score',
|
||||
.state('feedback.rateApp', {
|
||||
url: '/rateApp/:score',
|
||||
views: {
|
||||
'feedback': {
|
||||
controller: 'rateAppStoreController',
|
||||
templateUrl: 'views/feedback/rateAppStore.html'
|
||||
controller: 'rateAppController',
|
||||
templateUrl: 'views/feedback/rateApp.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -24,5 +24,35 @@ angular.module('copayApp.services').factory('feedbackService', function($http, $
|
|||
};
|
||||
};
|
||||
|
||||
root.isVersionUpdated = function(currentVersion, savedVersion) {
|
||||
|
||||
if (!verifyTagFormat(currentVersion))
|
||||
return 'Cannot verify the format of version tag: ' + currentVersion;
|
||||
if (!verifyTagFormat(savedVersion))
|
||||
return 'Cannot verify the format of the saved version tag: ' + savedVersion;
|
||||
|
||||
var current = formatTagNumber(currentVersion);
|
||||
var saved = formatTagNumber(savedVersion);
|
||||
if (saved.major > current.major || (saved.major == current.major && saved.minor > current.minor))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
function verifyTagFormat(tag) {
|
||||
var regex = /^v?\d+\.\d+\.\d+$/i;
|
||||
return regex.exec(tag);
|
||||
};
|
||||
|
||||
function formatTagNumber(tag) {
|
||||
var formattedNumber = tag.replace(/^v/i, '').split('.');
|
||||
return {
|
||||
major: +formattedNumber[0],
|
||||
minor: +formattedNumber[1],
|
||||
patch: +formattedNumber[2]
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -221,12 +221,12 @@ angular.module('copayApp.services')
|
|||
storage.remove('profile', cb);
|
||||
};
|
||||
|
||||
root.setProfileCreationTime = function(time, cb) {
|
||||
storage.set('profileCreationTime', time, cb);
|
||||
root.setFeedbackInfo = function(feedbackValues, cb) {
|
||||
storage.set('feedback', feedbackValues, cb);
|
||||
};
|
||||
|
||||
root.getProfileCreationTime = function(cb) {
|
||||
storage.get('profileCreationTime', cb);
|
||||
root.getFeedbackInfo = function(cb) {
|
||||
storage.get('feedback', cb);
|
||||
};
|
||||
|
||||
root.storeFocusedWalletId = function(id, cb) {
|
||||
|
|
@ -294,14 +294,6 @@ angular.module('copayApp.services')
|
|||
storage.set('homeTip', val, cb);
|
||||
};
|
||||
|
||||
root.getRateCardFlag = function(cb) {
|
||||
storage.get('rateCardFlag', cb);
|
||||
};
|
||||
|
||||
root.setRateCardFlag = function(val, cb) {
|
||||
storage.set('rateCardFlag', val, cb);
|
||||
};
|
||||
|
||||
root.setHideBalanceFlag = function(walletId, val, cb) {
|
||||
storage.set('hideBalance-' + walletId, val, cb);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#thanks-feedback {
|
||||
#complete {
|
||||
background-color: #ffffff;
|
||||
.item-heading {
|
||||
border-style: none;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#rate-app-store {
|
||||
#rate-app {
|
||||
background-color: #ffffff;
|
||||
.skip {
|
||||
margin: 10px;
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
@import "zero-state";
|
||||
@import "onboarding/onboarding";
|
||||
@import "feedback/rateCard";
|
||||
@import "feedback/sendFeedback";
|
||||
@import "feedback/thanks";
|
||||
@import "feedback/rateAppStore";
|
||||
@import "feedback/send";
|
||||
@import "feedback/complete";
|
||||
@import "feedback/rateApp";
|
||||
@import "includes/actionSheet";
|
||||
@import "export";
|
||||
@import "import";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<ion-view id="thanks-feedback">
|
||||
<ion-view id="complete">
|
||||
<ion-content scroll="false">
|
||||
<div class="item item-icon-right item-heading">
|
||||
<a ui-sref="tabs.home()"><i class="icon ion-ios-close-empty close-home-tip"></i></a>
|
||||
<a ui-sref="tabs.home"><i class="icon ion-ios-close-empty close-home-tip"></i></a>
|
||||
</div>
|
||||
<div ng-show="skipped && isCordova">
|
||||
<div class="title" translate>Invite friends to BitPay Wallet!</div>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<ion-view id="rate-app-store">
|
||||
<ion-view id="rate-app">
|
||||
<ion-content scroll="false">
|
||||
<a class="right skip" ng-click="skip()">Skip</a>
|
||||
<div class="title">
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="release ng-hide" ng-show="newRelease" ng-click="openExternalLink('https://github.com/bitpay/copay/releases/latest', true, 'Update Available', 'An update to this app is available. For your security, please update to the latest version.', 'View Update', 'Go Back')">
|
||||
<span translate>An update to this app is available</span><span><i class="icon bp-arrow-right"></i></span>
|
||||
</div>
|
||||
<div class="list card ng-hide" ng-show="!hideRateCard.value">
|
||||
<div class="list card ng-hide" ng-show="showRateCard.value">
|
||||
<span ng-include="'views/feedback/rateCard.html'"></span>
|
||||
</div>
|
||||
<div class="list card homeTip" ng-if="homeTip">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue