diff --git a/src/js/controller/mail-list.js b/src/js/controller/mail-list.js
index 824803e..29ebc1e 100644
--- a/src/js/controller/mail-list.js
+++ b/src/js/controller/mail-list.js
@@ -242,19 +242,19 @@ var MailListCtrl = function($scope, $routeParams) {
if (!searchText) {
// set display buffer to first messages
$scope.displayMessages = currentFolder().messages.slice(0, INIT_DISPLAY_LEN);
- $scope.searching = false;
+ setSearching(false);
updateStatus('Online');
return;
}
// display searching spinner
- $scope.searching = true;
+ setSearching(true);
updateStatus('Searching ...');
searchTimeout = setTimeout(function() {
$scope.$apply(function() {
// filter relevant messages
$scope.displayMessages = $scope.search(currentFolder().messages, searchText);
- $scope.searching = false;
+ setSearching(false);
updateStatus('Matches in this folder');
});
}, 500);
@@ -366,8 +366,12 @@ var MailListCtrl = function($scope, $routeParams) {
}
function updateStatus(lbl, time) {
- $scope.lastUpdateLbl = lbl;
- $scope.lastUpdate = (time) ? time : '';
+ $scope.state.mailList.lastUpdateLbl = lbl;
+ $scope.state.mailList.lastUpdate = (time) ? time : '';
+ }
+
+ function setSearching(state) {
+ $scope.state.mailList.searching = state;
}
function currentFolder() {
diff --git a/src/tpl/mail-list.html b/src/tpl/mail-list.html
index 9dd352b..5af937e 100644
--- a/src/tpl/mail-list.html
+++ b/src/tpl/mail-list.html
@@ -67,12 +67,12 @@
\ No newline at end of file
diff --git a/src/tpl/nav.html b/src/tpl/nav.html
index e352638..3787436 100644
--- a/src/tpl/nav.html
+++ b/src/tpl/nav.html
@@ -68,12 +68,12 @@
\ No newline at end of file
diff --git a/test/unit/mail-list-ctrl-test.js b/test/unit/mail-list-ctrl-test.js
index eed0b50..d05c1a8 100644
--- a/test/unit/mail-list-ctrl-test.js
+++ b/test/unit/mail-list-ctrl-test.js
@@ -137,8 +137,8 @@ describe('Mail List controller unit test', function() {
it('should show initial message on empty', function() {
scope.displaySearchResults();
- expect(scope.searching).to.be.false;
- expect(scope.lastUpdateLbl).to.equal('Online');
+ expect(scope.state.mailList.searching).to.be.false;
+ expect(scope.state.mailList.lastUpdateLbl).to.equal('Online');
expect(scope.displayMessages.length).to.equal(2);
});
it('should show initial message on empty', function() {
@@ -147,13 +147,13 @@ describe('Mail List controller unit test', function() {
scope.displaySearchResults('query');
- expect(scope.searching).to.be.true;
- expect(scope.lastUpdateLbl).to.equal('Searching ...');
+ expect(scope.state.mailList.searching).to.be.true;
+ expect(scope.state.mailList.lastUpdateLbl).to.equal('Searching ...');
clock.tick(500);
expect(scope.displayMessages).to.deep.equal(['a']);
- expect(scope.searching).to.be.false;
- expect(scope.lastUpdateLbl).to.equal('Matches in this folder');
+ expect(scope.state.mailList.searching).to.be.false;
+ expect(scope.state.mailList.lastUpdateLbl).to.equal('Matches in this folder');
});
});