зеркало из https://github.com/nextcloud/news.git
show unread count in title, fix #64
This commit is contained in:
Родитель
daa2c7dea5
Коммит
fd8a57477e
|
@ -24,10 +24,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
angular.module('News').controller 'FeedController',
|
||||
['$scope', '_ExistsError', 'Persistence', 'FolderBusinessLayer',
|
||||
'FeedBusinessLayer', 'SubscriptionsBusinessLayer', 'StarredBusinessLayer',
|
||||
'unreadCountFormatter', 'ActiveFeed', 'FeedType',
|
||||
'unreadCountFormatter', 'ActiveFeed', 'FeedType', '$window',
|
||||
($scope, _ExistsError, Persistence, FolderBusinessLayer, FeedBusinessLayer,
|
||||
SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter,
|
||||
ActiveFeed, FeedType) ->
|
||||
ActiveFeed, FeedType, $window) ->
|
||||
|
||||
|
||||
class FeedController
|
||||
|
@ -35,7 +35,7 @@ ActiveFeed, FeedType) ->
|
|||
constructor: (@_$scope, @_persistence, @_folderBusinessLayer,
|
||||
@_feedBusinessLayer, @_subscriptionsBusinessLayer,
|
||||
@_starredBusinessLayer, @_unreadCountFormatter,
|
||||
@_activeFeed, @_feedType) ->
|
||||
@_activeFeed, @_feedType, @_$window) ->
|
||||
|
||||
@_isAddingFolder = false
|
||||
@_isAddingFeed = false
|
||||
|
@ -47,6 +47,19 @@ ActiveFeed, FeedType) ->
|
|||
@_$scope.starredBusinessLayer = @_starredBusinessLayer
|
||||
@_$scope.unreadCountFormatter = @_unreadCountFormatter
|
||||
|
||||
@_$scope.getTotalUnreadCount = =>
|
||||
# also update title based on unreadcount
|
||||
count = @_subscriptionsBusinessLayer.getUnreadCount(0)
|
||||
|
||||
# dont do this for other dom elements
|
||||
# the title is some kind of exception since its always there
|
||||
# and it has nothing to do with the body structure
|
||||
if count > 0
|
||||
@_$window.document.title = 'News (' + count + ') | ownCloud'
|
||||
else
|
||||
@_$window.document.title = 'News | ownCloud'
|
||||
return count
|
||||
|
||||
@_$scope.isAddingFolder = =>
|
||||
return @_isAddingFolder
|
||||
|
||||
|
@ -116,6 +129,6 @@ ActiveFeed, FeedType) ->
|
|||
return new FeedController($scope, Persistence, FolderBusinessLayer,
|
||||
FeedBusinessLayer, SubscriptionsBusinessLayer,
|
||||
StarredBusinessLayer, unreadCountFormatter,
|
||||
ActiveFeed, FeedType)
|
||||
ActiveFeed, FeedType, $window)
|
||||
|
||||
]
|
|
@ -314,11 +314,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
(function() {
|
||||
angular.module('News').controller('FeedController', [
|
||||
'$scope', '_ExistsError', 'Persistence', 'FolderBusinessLayer', 'FeedBusinessLayer', 'SubscriptionsBusinessLayer', 'StarredBusinessLayer', 'unreadCountFormatter', 'ActiveFeed', 'FeedType', function($scope, _ExistsError, Persistence, FolderBusinessLayer, FeedBusinessLayer, SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter, ActiveFeed, FeedType) {
|
||||
'$scope', '_ExistsError', 'Persistence', 'FolderBusinessLayer', 'FeedBusinessLayer', 'SubscriptionsBusinessLayer', 'StarredBusinessLayer', 'unreadCountFormatter', 'ActiveFeed', 'FeedType', '$window', function($scope, _ExistsError, Persistence, FolderBusinessLayer, FeedBusinessLayer, SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter, ActiveFeed, FeedType, $window) {
|
||||
var FeedController;
|
||||
|
||||
FeedController = (function() {
|
||||
function FeedController(_$scope, _persistence, _folderBusinessLayer, _feedBusinessLayer, _subscriptionsBusinessLayer, _starredBusinessLayer, _unreadCountFormatter, _activeFeed, _feedType) {
|
||||
function FeedController(_$scope, _persistence, _folderBusinessLayer, _feedBusinessLayer, _subscriptionsBusinessLayer, _starredBusinessLayer, _unreadCountFormatter, _activeFeed, _feedType, _$window) {
|
||||
var _this = this;
|
||||
|
||||
this._$scope = _$scope;
|
||||
|
@ -330,6 +330,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
this._unreadCountFormatter = _unreadCountFormatter;
|
||||
this._activeFeed = _activeFeed;
|
||||
this._feedType = _feedType;
|
||||
this._$window = _$window;
|
||||
this._isAddingFolder = false;
|
||||
this._isAddingFeed = false;
|
||||
this._$scope.folderBusinessLayer = this._folderBusinessLayer;
|
||||
|
@ -337,6 +338,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
this._$scope.subscriptionsBusinessLayer = this._subscriptionsBusinessLayer;
|
||||
this._$scope.starredBusinessLayer = this._starredBusinessLayer;
|
||||
this._$scope.unreadCountFormatter = this._unreadCountFormatter;
|
||||
this._$scope.getTotalUnreadCount = function() {
|
||||
var count;
|
||||
|
||||
count = _this._subscriptionsBusinessLayer.getUnreadCount(0);
|
||||
if (count > 0) {
|
||||
_this._$window.document.title = 'News (' + count + ') | ownCloud';
|
||||
} else {
|
||||
_this._$window.document.title = 'News | ownCloud';
|
||||
}
|
||||
return count;
|
||||
};
|
||||
this._$scope.isAddingFolder = function() {
|
||||
return _this._isAddingFolder;
|
||||
};
|
||||
|
@ -410,7 +422,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
return FeedController;
|
||||
|
||||
})();
|
||||
return new FeedController($scope, Persistence, FolderBusinessLayer, FeedBusinessLayer, SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter, ActiveFeed, FeedType);
|
||||
return new FeedController($scope, Persistence, FolderBusinessLayer, FeedBusinessLayer, SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter, ActiveFeed, FeedType, $window);
|
||||
}
|
||||
]);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<li ng-class="{
|
||||
active: subscriptionsBusinessLayer.isActive(0),
|
||||
unread: subscriptionsBusinessLayer.getUnreadCount(0) > 0
|
||||
unread: getTotalUnreadCount() > 0
|
||||
}"
|
||||
ng-show="subscriptionsBusinessLayer.isVisible(0)">
|
||||
<a class="rss-icon"
|
||||
|
@ -17,8 +17,8 @@
|
|||
</a>
|
||||
<span class="utils">
|
||||
<span class="unread-counter"
|
||||
ng-show="subscriptionsBusinessLayer.getUnreadCount() > 0">
|
||||
{{ subscriptionsBusinessLayer.getUnreadCount() }}
|
||||
ng-show="getTotalUnreadCount() > 0">
|
||||
{{ getTotalUnreadCount() }}
|
||||
</span>
|
||||
<button class="svg action mark-read-icon"
|
||||
ng-click="subscriptionsBusinessLayer.markAllRead()"
|
||||
|
|
Загрузка…
Ссылка в новой задаче