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';
|
'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.score = parseInt($stateParams.score);
|
||||||
$scope.skipped = $stateParams.skipped == 'false' ? false : true;
|
$scope.skipped = $stateParams.skipped == 'false' ? false : true;
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
|
|
@ -31,7 +31,12 @@ angular.module('copayApp.controllers').controller('thanksController', function($
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$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;
|
if (!$scope.isCordova) return;
|
||||||
|
|
||||||
window.plugins.socialsharing.available(function(isAvailable) {
|
window.plugins.socialsharing.available(function(isAvailable) {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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);
|
$scope.score = parseInt($stateParams.score);
|
||||||
var isAndroid = platformInfo.isAndroid;
|
var isAndroid = platformInfo.isAndroid;
|
||||||
var isIOS = platformInfo.isIOS;
|
var isIOS = platformInfo.isIOS;
|
||||||
|
|
@ -8,14 +8,14 @@ angular.module('copayApp.controllers').controller('rateAppStoreController', func
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
|
|
||||||
$scope.skip = function() {
|
$scope.skip = function() {
|
||||||
$state.go('feedback.thanks', {
|
$state.go('feedback.complete', {
|
||||||
score: $scope.score,
|
score: $scope.score,
|
||||||
skipped: true
|
skipped: true
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.sendFeedback = function() {
|
$scope.sendFeedback = function() {
|
||||||
$state.go('feedback.sendFeedback', {
|
$state.go('feedback.send', {
|
||||||
score: $scope.score
|
score: $scope.score
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -10,11 +10,11 @@ angular.module('copayApp.controllers').controller('rateCardController', function
|
||||||
$scope.rateModal.remove();
|
$scope.rateModal.remove();
|
||||||
}
|
}
|
||||||
if ($scope.isCordova && $scope.score == 5) {
|
if ($scope.isCordova && $scope.score == 5) {
|
||||||
$state.go('feedback.rateAppStore', {
|
$state.go('feedback.rateApp', {
|
||||||
score: $scope.score
|
score: $scope.score
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$state.go('feedback.sendFeedback', {
|
$state.go('feedback.send', {
|
||||||
score: $scope.score
|
score: $scope.score
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -49,8 +49,10 @@ angular.module('copayApp.controllers').controller('rateCardController', function
|
||||||
$scope.rateModal.hide();
|
$scope.rateModal.hide();
|
||||||
$scope.rateModal.remove();
|
$scope.rateModal.remove();
|
||||||
} else {
|
} else {
|
||||||
storageService.setRateCardFlag('true', function() {
|
storageService.getFeedbackInfo(function(error, info) {
|
||||||
$scope.hideRateCard.value = true;
|
var feedbackInfo = JSON.parse(info);
|
||||||
|
feedbackInfo.sent = true;
|
||||||
|
storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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);
|
$scope.score = parseInt($stateParams.score);
|
||||||
switch ($scope.score) {
|
switch ($scope.score) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
@ -42,7 +42,7 @@ angular.module('copayApp.controllers').controller('sendFeedbackController', func
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send feedback'));
|
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send feedback'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$state.go('feedback.thanks', {
|
$state.go('feedback.complete', {
|
||||||
score: $stateParams.score,
|
score: $stateParams.score,
|
||||||
skipped: skip
|
skipped: skip
|
||||||
});
|
});
|
||||||
|
|
@ -19,13 +19,7 @@ angular.module('copayApp.controllers').controller('welcomeController', function(
|
||||||
$log.debug('Creating profile');
|
$log.debug('Creating profile');
|
||||||
profileService.createProfile(function(err) {
|
profileService.createProfile(function(err) {
|
||||||
if (err) $log.warn(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';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
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 wallet;
|
||||||
var listeners = [];
|
var listeners = [];
|
||||||
var notifications = [];
|
var notifications = [];
|
||||||
|
|
@ -13,7 +13,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
$scope.isAndroid = platformInfo.isAndroid;
|
$scope.isAndroid = platformInfo.isAndroid;
|
||||||
$scope.isNW = platformInfo.isNW;
|
$scope.isNW = platformInfo.isNW;
|
||||||
$scope.hideRateCard = {};
|
$scope.showRateCard = {};
|
||||||
|
|
||||||
$scope.$on("$ionicView.afterEnter", function() {
|
$scope.$on("$ionicView.afterEnter", function() {
|
||||||
startupService.ready();
|
startupService.ready();
|
||||||
|
|
@ -37,13 +37,37 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
storageService.getProfileCreationTime(function(error, time) {
|
storageService.getFeedbackInfo(function(error, info) {
|
||||||
var now = moment().unix() * 1000;
|
if (!info) {
|
||||||
storageService.getRateCardFlag(function(error, value) {
|
initFeedBackInfo();
|
||||||
$scope.hideRateCard.value = (value == 'true' || (time - now) > 0) ? true : false;
|
} 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) {
|
$scope.$on("$ionicView.enter", function(event, data) {
|
||||||
|
|
|
||||||
|
|
@ -731,30 +731,30 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
abstract: true,
|
abstract: true,
|
||||||
template: '<ion-nav-view name="feedback"></ion-nav-view>'
|
template: '<ion-nav-view name="feedback"></ion-nav-view>'
|
||||||
})
|
})
|
||||||
.state('feedback.sendFeedback', {
|
.state('feedback.send', {
|
||||||
url: '/sendFeedback/:score',
|
url: '/send/:score',
|
||||||
views: {
|
views: {
|
||||||
'feedback': {
|
'feedback': {
|
||||||
controller: 'sendFeedbackController',
|
controller: 'sendController',
|
||||||
templateUrl: 'views/feedback/sendFeedback.html'
|
templateUrl: 'views/feedback/send.html'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('feedback.thanks', {
|
.state('feedback.complete', {
|
||||||
url: '/thanks/:score/:skipped',
|
url: '/complete/:score/:skipped',
|
||||||
views: {
|
views: {
|
||||||
'feedback': {
|
'feedback': {
|
||||||
controller: 'thanksController',
|
controller: 'completeController',
|
||||||
templateUrl: 'views/feedback/thanks.html'
|
templateUrl: 'views/feedback/complete.html'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('feedback.rateAppStore', {
|
.state('feedback.rateApp', {
|
||||||
url: '/rateAppStore/:score',
|
url: '/rateApp/:score',
|
||||||
views: {
|
views: {
|
||||||
'feedback': {
|
'feedback': {
|
||||||
controller: 'rateAppStoreController',
|
controller: 'rateAppController',
|
||||||
templateUrl: 'views/feedback/rateAppStore.html'
|
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;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -221,12 +221,12 @@ angular.module('copayApp.services')
|
||||||
storage.remove('profile', cb);
|
storage.remove('profile', cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.setProfileCreationTime = function(time, cb) {
|
root.setFeedbackInfo = function(feedbackValues, cb) {
|
||||||
storage.set('profileCreationTime', time, cb);
|
storage.set('feedback', feedbackValues, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getProfileCreationTime = function(cb) {
|
root.getFeedbackInfo = function(cb) {
|
||||||
storage.get('profileCreationTime', cb);
|
storage.get('feedback', cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.storeFocusedWalletId = function(id, cb) {
|
root.storeFocusedWalletId = function(id, cb) {
|
||||||
|
|
@ -294,14 +294,6 @@ angular.module('copayApp.services')
|
||||||
storage.set('homeTip', val, cb);
|
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) {
|
root.setHideBalanceFlag = function(walletId, val, cb) {
|
||||||
storage.set('hideBalance-' + walletId, val, cb);
|
storage.set('hideBalance-' + walletId, val, cb);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#thanks-feedback {
|
#complete {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
.item-heading {
|
.item-heading {
|
||||||
border-style: none;
|
border-style: none;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#rate-app-store {
|
#rate-app {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
.skip {
|
.skip {
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
@import "zero-state";
|
@import "zero-state";
|
||||||
@import "onboarding/onboarding";
|
@import "onboarding/onboarding";
|
||||||
@import "feedback/rateCard";
|
@import "feedback/rateCard";
|
||||||
@import "feedback/sendFeedback";
|
@import "feedback/send";
|
||||||
@import "feedback/thanks";
|
@import "feedback/complete";
|
||||||
@import "feedback/rateAppStore";
|
@import "feedback/rateApp";
|
||||||
@import "includes/actionSheet";
|
@import "includes/actionSheet";
|
||||||
@import "export";
|
@import "export";
|
||||||
@import "import";
|
@import "import";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<ion-view id="thanks-feedback">
|
<ion-view id="complete">
|
||||||
<ion-content scroll="false">
|
<ion-content scroll="false">
|
||||||
<div class="item item-icon-right item-heading">
|
<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>
|
||||||
<div ng-show="skipped && isCordova">
|
<div ng-show="skipped && isCordova">
|
||||||
<div class="title" translate>Invite friends to BitPay Wallet!</div>
|
<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">
|
<ion-content scroll="false">
|
||||||
<a class="right skip" ng-click="skip()">Skip</a>
|
<a class="right skip" ng-click="skip()">Skip</a>
|
||||||
<div class="title">
|
<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')">
|
<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>
|
<span translate>An update to this app is available</span><span><i class="icon bp-arrow-right"></i></span>
|
||||||
</div>
|
</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>
|
<span ng-include="'views/feedback/rateCard.html'"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="list card homeTip" ng-if="homeTip">
|
<div class="list card homeTip" ng-if="homeTip">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue