From f0f0aa3d6349db17abe81bbc03e918e57260dec3 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Sat, 29 Mar 2014 01:14:52 +0100 Subject: [PATCH] Fix show messages on initial login/folder-sync --- src/js/controller/navigation.js | 16 ++++++++++++++-- src/js/dao/email-dao.js | 18 +----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/js/controller/navigation.js b/src/js/controller/navigation.js index 9e33930..1deb6fb 100644 --- a/src/js/controller/navigation.js +++ b/src/js/controller/navigation.js @@ -66,9 +66,21 @@ define(function(require) { // init folders initFolders(); // select inbox as the current folder on init - $scope.openFolder($scope.account.folders[0]); + if ($scope.account.folders && $scope.account.folders.length > 0) { + $scope.openFolder($scope.account.folders[0]); + } // connect imap/smtp clients on first startup - appController.onConnect($scope.onError); + appController.onConnect(function(err) { + if (err) { + $scope.onError(err); + return; + } + + // select inbox if not yet selected + if (!$scope.state.nav.currentFolder) { + $scope.openFolder($scope.account.folders[0]); + } + }); // // helper functions diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 78d1fc6..6704f0b 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -73,23 +73,7 @@ define(function(require) { return; } - // if empty (first time login) use dummy folders ... overwritten in onConnect - self._account.folders = (folders) ? folders : [{ - type: 'Inbox', - path: 'INBOX' - }, { - type: 'Sent', - path: 'SENT' - }, { - type: 'Outbox', - path: 'OUTBOX' - }, { - type: 'Drafts', - path: 'DRAFTS' - }, { - type: 'Trash', - path: 'TRASH' - }]; + self._account.folders = folders; callback(null, keypair); });