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:
parent
63d1d12d71
commit
836456f0d0
@ -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'
|
||||
});
|
||||
});
|
||||
|
||||
|
27
src/js/controller/login.js
Normal file
27
src/js/controller/login.js
Normal 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;
|
||||
});
|
@ -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
1
src/tpl/login.html
Normal file
@ -0,0 +1 @@
|
||||
<div class="message">Logging in...</div>
|
Loading…
Reference in New Issue
Block a user