add logic to display grouping labels appropriately

This commit is contained in:
Marty Alcala 2016-11-02 16:35:05 -04:00
commit e41b46b42d
2 changed files with 18 additions and 1 deletions

View file

@ -156,6 +156,23 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
return new Date(txCreated * 1000);
};
$scope.showGroupHeader = function(index) {
if(index === 0) {
return true;
}
var curTx = $scope.txHistory[index];
var prevTx = $scope.txHistory[index - 1];
return !createdDuringSameMonth(curTx, prevTx);
};
function createdDuringSameMonth(tx1, tx2) {
var date1 = new Date(tx1.time * 1000);
var date2 = new Date(tx2.time * 1000);
var date1MonthYear = date1.getMonth() + date1.getFullYear();
var date2MonthYear = date2.getMonth() + date2.getFullYear();
return date1MonthYear === date2MonthYear;
}
$scope.showMore = function() {
$timeout(function() {
currentTxHistoryPage++;

View file

@ -176,7 +176,7 @@
<div class="wallet-details__list" ng-show="txHistory[0]">
<div ng-repeat="btx in txHistory track by $index" ng-click="openTxModal(btx)">
<div class="wallet-details__group-label">{{getDate(btx.time) | date:'MMMM'}}</div>
<div class="wallet-details__group-label" ng-if="showGroupHeader($index)">{{getDate(btx.time) | date:'MMMM'}}</div>
<div class="wallet-details__item">
<img class="wallet-details__tx-icon" src="img/icon-tx-received.svg" width="40" ng-if="btx.action == 'received'">