1
0
mirror of https://github.com/moparisthebest/mail synced 2025-01-31 07:00:17 -05:00

init app controller centrally before login

This commit is contained in:
Tankred Hase 2013-09-15 16:24:14 +02:00
parent 63d1d12d71
commit 836456f0d0
4 changed files with 48 additions and 25 deletions

View File

@ -3,16 +3,20 @@ window.name = 'NG_DEFER_BOOTSTRAP!';
require([
'angular',
'js/controller/login',
'js/controller/message-list',
'js/controller/write',
'angularRoute',
'angularTouch',
'js/app-config'
], function(angular, MessageListCtrl, WriteCtrl) {
'angularTouch'
], function(angular, LoginCtrl, MessageListCtrl, WriteCtrl) {
'use strict';
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'write']);
app.config(function($routeProvider) {
$routeProvider.when('/login', {
templateUrl: 'tpl/login.html',
controller: LoginCtrl
});
$routeProvider.when('/folders/:folder', {
templateUrl: 'tpl/message-list-desktop.html',
controller: MessageListCtrl
@ -26,7 +30,7 @@ require([
controller: WriteCtrl
});
$routeProvider.otherwise({
redirectTo: '/folders/Inbox'
redirectTo: '/login'
});
});

View File

@ -0,0 +1,27 @@
define(function(require) {
'use strict';
var appController = require('js/app-controller');
var LoginCtrl = function($scope, $location) {
var nextPath = '/folders/INBOX';
if (window.chrome && chrome.identity) {
// start the main app controller
appController.fetchOAuthToken('passphrase', function(err) {
if (err) {
console.log(err);
return;
}
$location.path(nextPath);
$scope.$apply();
});
return;
}
$location.path(nextPath);
};
return LoginCtrl;
});

View File

@ -32,7 +32,7 @@ define(function(require) {
};
if (window.chrome && chrome.identity) {
fetchList(function(emails) {
fetchList($scope.folder, function(emails) {
$scope.emails = emails;
$scope.select($scope.emails[0]);
$scope.$apply();
@ -46,15 +46,7 @@ define(function(require) {
});
};
function fetchList(callback) {
var folder = 'INBOX';
appController.fetchOAuthToken('passphrase', function(err) {
if (err) {
console.log(err);
return;
}
function fetchList(folder, callback) {
// fetch imap folder's message list
appController._emailDao.imapListMessages({
folder: folder,
@ -72,7 +64,6 @@ define(function(require) {
callback(messages);
});
});
});
}
function fetchBodies(messageList, folder, callback) {

1
src/tpl/login.html Normal file
View File

@ -0,0 +1 @@
<div class="message">Logging in...</div>