mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-03-10 06:10:14 +01:00
Fix account switcher: use currentEmail as ng-model so display updates immediately
This commit is contained in:
@@ -109,7 +109,6 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($
|
||||
// ── State ────────────────────────────────────────────────
|
||||
$scope.currentEmail = '';
|
||||
$scope.managedAccounts = [];
|
||||
$scope.switchEmail = '';
|
||||
$scope.folders = [];
|
||||
$scope.currentFolder = 'INBOX';
|
||||
$scope.messages = [];
|
||||
@@ -169,7 +168,6 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($
|
||||
if (data.status === 1) {
|
||||
$scope.currentEmail = data.email;
|
||||
$scope.managedAccounts = data.accounts || [];
|
||||
$scope.switchEmail = data.email;
|
||||
$scope.loadFolders();
|
||||
$scope.loadSettings();
|
||||
} else {
|
||||
@@ -180,10 +178,10 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($
|
||||
|
||||
// ── Account Switching ────────────────────────────────────
|
||||
$scope.switchAccount = function() {
|
||||
if (!$scope.switchEmail || $scope.switchEmail === $scope.currentEmail) return;
|
||||
apiCall('/webmail/api/switchAccount', {email: $scope.switchEmail}, function(data) {
|
||||
var newEmail = $scope.currentEmail;
|
||||
if (!newEmail) return;
|
||||
apiCall('/webmail/api/switchAccount', {email: newEmail}, function(data) {
|
||||
if (data.status === 1) {
|
||||
$scope.currentEmail = data.email;
|
||||
$scope.currentFolder = 'INBOX';
|
||||
$scope.currentPage = 1;
|
||||
$scope.openMsg = null;
|
||||
@@ -195,8 +193,10 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($
|
||||
$scope.loadFolders();
|
||||
$scope.loadSettings();
|
||||
} else {
|
||||
notify(data.error_message, 'error');
|
||||
notify(data.error_message || 'Failed to switch account', 'error');
|
||||
}
|
||||
}, function() {
|
||||
notify('Failed to switch account', 'error');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<span>{$ currentEmail $}</span>
|
||||
</div>
|
||||
<div class="wm-account-switch">
|
||||
<select ng-model="switchEmail" ng-change="switchAccount()"
|
||||
<select ng-model="currentEmail" ng-change="switchAccount()"
|
||||
ng-options="a for a in managedAccounts" class="wm-account-select">
|
||||
</select>
|
||||
</div>
|
||||
@@ -435,6 +435,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{% static 'webmail/webmail.js' %}?v=2"></script>
|
||||
<script src="{% static 'webmail/webmail.js' %}?v=3"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user