Allow deeplinking into the mail view
This commit is contained in:
@@ -4,12 +4,31 @@
|
||||
/* global $ */
|
||||
/* global async */
|
||||
|
||||
angular.module('Application').controller('EmailController', ['$scope', '$location', '$translate', '$timeout', '$routeParams', 'Client', function ($scope, $location, $translate, $timeout, $routeParams, Client) {
|
||||
angular.module('Application').controller('EmailController', ['$scope', '$location', '$translate', '$timeout', '$route', '$routeParams', 'Client', function ($scope, $location, $translate, $timeout, $route, $routeParams, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
|
||||
|
||||
// Avoid full reload on path change
|
||||
// https://stackoverflow.com/a/22614334
|
||||
// reloadOnUrl: false in $routeProvider did not work!
|
||||
var lastRoute = $route.current;
|
||||
$scope.$on('$locationChangeSuccess', function (/* event */) {
|
||||
if (lastRoute.$$route.originalPath === $route.current.$$route.originalPath) {
|
||||
$route.current = lastRoute;
|
||||
}
|
||||
});
|
||||
|
||||
var domainName = $routeParams.domain;
|
||||
if (!domainName) return $location.path('/email');
|
||||
|
||||
$scope.setView = function (view, setAlways) {
|
||||
if (!setAlways && !$scope.ready) return;
|
||||
if ($scope.view === view) return;
|
||||
|
||||
$route.updateParams({ view: view });
|
||||
$scope.view = view;
|
||||
$scope.activeTab = view;
|
||||
};
|
||||
|
||||
$scope.ready = false;
|
||||
$scope.refreshBusy = true;
|
||||
$scope.client = Client;
|
||||
@@ -803,6 +822,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
}, function iteratorDone(error) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.setView($routeParams.view || 'mailboxes', true /* always set */);
|
||||
$scope.ready = true;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user