Fixed app reload for packaged app
This commit is contained in:
parent
f82fd9db08
commit
f141abe049
@ -305,7 +305,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
ChangelogNotifyService.checkUpdate();
|
||||
})
|
||||
|
||||
.controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, ContactsSelectService, ChangelogNotifyService, ErrorService) {
|
||||
.controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, ContactsSelectService, ChangelogNotifyService, ErrorService, AppRuntimeManager) {
|
||||
|
||||
$scope.$on('$routeUpdate', updateCurDialog);
|
||||
|
||||
@ -382,7 +382,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
ErrorService.confirm({type: 'LOGOUT'}).then(function () {
|
||||
MtpApiManager.logOut().then(function () {
|
||||
location.hash = '/login';
|
||||
location.reload();
|
||||
AppRuntimeManager.reload();
|
||||
});
|
||||
})
|
||||
};
|
||||
@ -1455,7 +1455,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
}
|
||||
})
|
||||
|
||||
.controller('AppLangFooterController', function ($scope, _, Storage, ErrorService) {
|
||||
.controller('AppLangFooterController', function ($scope, _, Storage, ErrorService, AppRuntimeManager) {
|
||||
$scope.supportedLocales = Config.I18n.supported;
|
||||
$scope.langNames = Config.I18n.languages;
|
||||
$scope.curLocale = Config.I18n.locale;
|
||||
@ -1464,7 +1464,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
Storage.set({i18n_locale: newLocale});
|
||||
if ($scope.curLocale !== newLocale) {
|
||||
ErrorService.confirm({type: 'APPLY_LANG_WITH_RELOAD'}).then(function () {
|
||||
location.reload();
|
||||
AppRuntimeManager.reload();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -569,6 +569,34 @@ angular.module('izhukov.utils', [])
|
||||
};
|
||||
})
|
||||
|
||||
.service('AppRuntimeManager', function ($window) {
|
||||
|
||||
return {
|
||||
reload: function () {
|
||||
try {
|
||||
location.reload();
|
||||
} catch (e) {};
|
||||
|
||||
if ($window.chrome && chrome.runtime && chrome.runtime.reload) {
|
||||
chrome.runtime.reload();
|
||||
};
|
||||
},
|
||||
focus: function () {
|
||||
if (window.navigator.mozApps && document.hidden) {
|
||||
// Get app instance and launch it to bring app to foreground
|
||||
window.navigator.mozApps.getSelf().onsuccess = function() {
|
||||
this.result.launch();
|
||||
};
|
||||
} else {
|
||||
if (window.chrome && chrome.app && chrome.app.window) {
|
||||
chrome.app.window.current().focus();
|
||||
}
|
||||
window.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -3448,7 +3448,7 @@ angular.module('myApp.services', ['myApp.i18n'])
|
||||
|
||||
})
|
||||
|
||||
.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, $q, MtpApiManager, AppPeersManager, IdleManager, Storage) {
|
||||
.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, $q, MtpApiManager, AppPeersManager, IdleManager, Storage, AppRuntimeManager) {
|
||||
|
||||
navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate;
|
||||
|
||||
@ -3647,17 +3647,7 @@ angular.module('myApp.services', ['myApp.i18n'])
|
||||
|
||||
notification.onclick = function () {
|
||||
notification.close();
|
||||
if (window.navigator.mozApps && document.hidden) {
|
||||
// Get app instance and launch it to bring app to foreground
|
||||
window.navigator.mozApps.getSelf().onsuccess = function() {
|
||||
this.result.launch();
|
||||
};
|
||||
} else {
|
||||
if (window.chrome && chrome.app && chrome.app.window) {
|
||||
chrome.app.window.current().focus();
|
||||
}
|
||||
window.focus();
|
||||
}
|
||||
AppRuntimeManager.focus();
|
||||
notificationsClear();
|
||||
if (data.onclick) {
|
||||
data.onclick();
|
||||
|
Loading…
Reference in New Issue
Block a user