feat(home): refresh new torrents and opened tickets status when torrent was reviewed or tickets was replied.

This commit is contained in:
OldHawk
2018-06-10 18:04:03 +08:00
parent c785b0dd48
commit d0f27f9704
4 changed files with 25 additions and 8 deletions

View File

@@ -154,6 +154,20 @@
vm.getCountUnread();
});
/**
* new-torrents-changed
*/
$scope.$on('new-torrents-changed', function (event, args) {
vm.getNewTorrentsCount();
});
/**
* opened-tickets-changed
*/
$scope.$on('opened-tickets-changed', function (event, args) {
vm.getTicketsOpenedCount();
});
/**
* user-invitations-changed
*/

View File

@@ -5,9 +5,9 @@
.directive('torrentListItem', torrentListItem);
function torrentListItem() {
var TorrentsItemController = ['$scope', '$state', 'TorrentGetInfoServices', 'ResourcesTagsServices', '$timeout', 'DownloadService', 'MeanTorrentConfig',
var TorrentsItemController = ['$scope', '$rootScope', '$state', 'TorrentGetInfoServices', 'ResourcesTagsServices', '$timeout', 'DownloadService', 'MeanTorrentConfig',
'TorrentsService', 'Authentication', 'NotifycationService', 'ModalConfirmService', '$translate', 'moment',
function ($scope, $state, TorrentGetInfoServices, ResourcesTagsServices, $timeout, DownloadService, MeanTorrentConfig, TorrentsService, Authentication,
function ($scope, $rootScope, $state, TorrentGetInfoServices, ResourcesTagsServices, $timeout, DownloadService, MeanTorrentConfig, TorrentsService, Authentication,
NotifycationService, ModalConfirmService, $translate, moment) {
var vm = this;
@@ -292,6 +292,7 @@
_torrentId: item._id
}, function (res) {
$scope.list[$scope.list.indexOf(item)] = res;
$rootScope.$broadcast('new-torrents-changed');
NotifycationService.showSuccessNotify('TORRENT_SETREVIEWED_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'TORRENT_SETREVIEWED_ERROR');

View File

@@ -5,11 +5,11 @@
.module('tickets')
.controller('ViewMessageTicketController', ViewMessageTicketController);
ViewMessageTicketController.$inject = ['$scope', '$state', '$timeout', '$translate', 'Authentication', 'MessageTicketsService', 'ModalConfirmService', 'NotifycationService', 'marked',
'DebugConsoleService', 'MeanTorrentConfig', '$filter', '$stateParams', 'Upload', 'localStorageService', '$compile'];
ViewMessageTicketController.$inject = ['$scope', '$rootScope', '$state', '$timeout', '$translate', 'Authentication', 'MessageTicketsService', 'ModalConfirmService',
'NotifycationService', 'marked', 'DebugConsoleService', 'MeanTorrentConfig', '$filter', '$stateParams', 'Upload', 'localStorageService', '$compile'];
function ViewMessageTicketController($scope, $state, $timeout, $translate, Authentication, MessageTicketsService, ModalConfirmService, NotifycationService, marked,
mtDebug, MeanTorrentConfig, $filter, $stateParams, Upload, localStorageService, $compile) {
function ViewMessageTicketController($scope, $rootScope, $state, $timeout, $translate, Authentication, MessageTicketsService, ModalConfirmService,
NotifycationService, marked, mtDebug, MeanTorrentConfig, $filter, $stateParams, Upload, localStorageService, $compile) {
var vm = this;
vm.user = Authentication.user;
vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage;
@@ -154,6 +154,7 @@
vm.postReplyFields = {};
vm.currentPage = Math.ceil(res._replies.length / vm.itemsPerPage);
vm.ticket = res;
$rootScope.$broadcast('opened-tickets-changed');
vm.pageChanged();
$scope.$broadcast('show-errors-reset', 'vm.replyForm');

View File

@@ -5,12 +5,12 @@
.module('torrents')
.controller('TorrentsInfoController', TorrentsInfoController);
TorrentsInfoController.$inject = ['$scope', '$state', '$stateParams', '$translate', 'Authentication', 'Notification', 'TorrentsService',
TorrentsInfoController.$inject = ['$scope', '$rootScope', '$state', '$stateParams', '$translate', 'Authentication', 'Notification', 'TorrentsService',
'MeanTorrentConfig', 'DownloadService', '$sce', '$filter', 'CommentsService', 'ModalConfirmService', 'marked', 'Upload', '$timeout',
'SubtitlesService', 'getStorageLangService', 'NotifycationService', 'DebugConsoleService', 'TorrentGetInfoServices', 'AlbumsService',
'localStorageService', '$compile', 'SideOverlay', 'ResourcesTagsServices', 'CollectionsService', 'moment'];
function TorrentsInfoController($scope, $state, $stateParams, $translate, Authentication, Notification, TorrentsService, MeanTorrentConfig,
function TorrentsInfoController($scope, $rootScope, $state, $stateParams, $translate, Authentication, Notification, TorrentsService, MeanTorrentConfig,
DownloadService, $sce, $filter, CommentsService, ModalConfirmService, marked, Upload, $timeout, SubtitlesService,
getStorageLangService, NotifycationService, mtDebug, TorrentGetInfoServices, AlbumsService,
localStorageService, $compile, SideOverlay, ResourcesTagsServices, CollectionsService, moment) {
@@ -191,6 +191,7 @@
_torrentId: vm.torrentLocalInfo._id
}, function (res) {
vm.torrentLocalInfo = res;
$rootScope.$broadcast('new-torrents-changed');
NotifycationService.showSuccessNotify('TORRENT_SETREVIEWED_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'TORRENT_SETREVIEWED_ERROR');