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); });