зеркало из https://github.com/nextcloud/news.git
reload page after showall has been changed
This commit is contained in:
Родитель
2d8f76d28f
Коммит
27f34bcb4b
|
@ -23,13 +23,14 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
angular.module('News').factory 'FeedBl',
|
||||
['_Bl', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel',
|
||||
'FeedModel',
|
||||
(_Bl, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel) ->
|
||||
'FeedModel', 'NewLoading',
|
||||
(_Bl, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel,
|
||||
NewLoading) ->
|
||||
|
||||
class FeedBl extends _Bl
|
||||
|
||||
constructor: (@_showAll, @_feedModel, persistence, activeFeed, feedType,
|
||||
itemModel) ->
|
||||
itemModel, @_newLoading) ->
|
||||
super(activeFeed, persistence, itemModel, feedType.Feed)
|
||||
|
||||
|
||||
|
@ -92,15 +93,22 @@ angular.module('News').factory 'FeedBl',
|
|||
|
||||
setShowAll: (showAll) ->
|
||||
@_showAll.setShowAll(showAll)
|
||||
@_persistence.getItems(
|
||||
@_activeFeed.getType(),
|
||||
@_activeFeed.getId(),
|
||||
0
|
||||
)
|
||||
|
||||
# TODO: this callback is not tested with a unittest
|
||||
callback = =>
|
||||
@_itemModel.clear()
|
||||
@_newLoading.increase()
|
||||
@_persistence.getItems(
|
||||
@_activeFeed.getType(),
|
||||
@_activeFeed.getId(),
|
||||
0,
|
||||
=>
|
||||
@_newLoading.decrease()
|
||||
)
|
||||
if showAll
|
||||
@_persistence.userSettingsReadShow()
|
||||
@_persistence.userSettingsReadShow(callback)
|
||||
else
|
||||
@_persistence.userSettingsReadHide()
|
||||
@_persistence.userSettingsReadHide(callback)
|
||||
|
||||
|
||||
isShowAll: ->
|
||||
|
@ -112,6 +120,6 @@ angular.module('News').factory 'FeedBl',
|
|||
|
||||
|
||||
return new FeedBl(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType,
|
||||
ItemModel)
|
||||
ItemModel, NewLoading)
|
||||
|
||||
]
|
|
@ -302,18 +302,22 @@ angular.module('News').factory '_Persistence', ->
|
|||
@_request.get 'news_usersettings_read', params
|
||||
|
||||
|
||||
userSettingsReadShow: ->
|
||||
userSettingsReadShow: (callback) ->
|
||||
###
|
||||
Sets the reader mode to show all
|
||||
###
|
||||
@_request.post 'news_usersettings_read_show'
|
||||
data =
|
||||
onSuccess: callback
|
||||
@_request.post 'news_usersettings_read_show', data
|
||||
|
||||
|
||||
userSettingsReadHide: ->
|
||||
userSettingsReadHide: (callback) ->
|
||||
###
|
||||
Sets the reader mode to show only unread
|
||||
###
|
||||
@_request.post 'news_usersettings_read_hide'
|
||||
data =
|
||||
onSuccess: callback
|
||||
@_request.post 'news_usersettings_read_hide', data
|
||||
|
||||
|
||||
_triggerHideRead: ->
|
||||
|
|
|
@ -551,15 +551,16 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
angular.module('News').factory('FeedBl', [
|
||||
'_Bl', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', function(_Bl, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel) {
|
||||
'_Bl', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewLoading', function(_Bl, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel, NewLoading) {
|
||||
var FeedBl;
|
||||
FeedBl = (function(_super) {
|
||||
|
||||
__extends(FeedBl, _super);
|
||||
|
||||
function FeedBl(_showAll, _feedModel, persistence, activeFeed, feedType, itemModel) {
|
||||
function FeedBl(_showAll, _feedModel, persistence, activeFeed, feedType, itemModel, _newLoading) {
|
||||
this._showAll = _showAll;
|
||||
this._feedModel = _feedModel;
|
||||
this._newLoading = _newLoading;
|
||||
FeedBl.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Feed);
|
||||
}
|
||||
|
||||
|
@ -638,12 +639,20 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
};
|
||||
|
||||
FeedBl.prototype.setShowAll = function(showAll) {
|
||||
var callback,
|
||||
_this = this;
|
||||
this._showAll.setShowAll(showAll);
|
||||
this._persistence.getItems(this._activeFeed.getType(), this._activeFeed.getId(), 0);
|
||||
callback = function() {
|
||||
_this._itemModel.clear();
|
||||
_this._newLoading.increase();
|
||||
return _this._persistence.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), 0, function() {
|
||||
return _this._newLoading.decrease();
|
||||
});
|
||||
};
|
||||
if (showAll) {
|
||||
return this._persistence.userSettingsReadShow();
|
||||
return this._persistence.userSettingsReadShow(callback);
|
||||
} else {
|
||||
return this._persistence.userSettingsReadHide();
|
||||
return this._persistence.userSettingsReadHide(callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -658,7 +667,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
return FeedBl;
|
||||
|
||||
})(_Bl);
|
||||
return new FeedBl(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel);
|
||||
return new FeedBl(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel, NewLoading);
|
||||
}
|
||||
]);
|
||||
|
||||
|
@ -1932,18 +1941,28 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
return this._request.get('news_usersettings_read', params);
|
||||
};
|
||||
|
||||
Persistence.prototype.userSettingsReadShow = function() {
|
||||
Persistence.prototype.userSettingsReadShow = function(callback) {
|
||||
/*
|
||||
Sets the reader mode to show all
|
||||
*/
|
||||
return this._request.post('news_usersettings_read_show');
|
||||
|
||||
var data;
|
||||
data = {
|
||||
onSuccess: callback
|
||||
};
|
||||
return this._request.post('news_usersettings_read_show', data);
|
||||
};
|
||||
|
||||
Persistence.prototype.userSettingsReadHide = function() {
|
||||
Persistence.prototype.userSettingsReadHide = function(callback) {
|
||||
/*
|
||||
Sets the reader mode to show only unread
|
||||
*/
|
||||
return this._request.post('news_usersettings_read_hide');
|
||||
|
||||
var data;
|
||||
data = {
|
||||
onSuccess: callback
|
||||
};
|
||||
return this._request.post('news_usersettings_read_hide', data);
|
||||
};
|
||||
|
||||
Persistence.prototype._triggerHideRead = function() {
|
||||
|
|
|
@ -190,15 +190,6 @@ describe 'FeedBl', ->
|
|||
expect(@FeedBl.isShowAll()).toBe(true)
|
||||
|
||||
|
||||
it 'should reload the active feed if showall changed', =>
|
||||
@persistence.userSettingsReadShow = jasmine.createSpy('Show All')
|
||||
@persistence.userSettingsReadHide = jasmine.createSpy('Hide All')
|
||||
|
||||
@FeedBl.setShowAll(true)
|
||||
|
||||
expect(@getItemsSpy).toHaveBeenCalledWith(@FeedType.Folder, 0, 0)
|
||||
|
||||
|
||||
it 'should return all feeds of a folder', =>
|
||||
item1 = {id: 2, unreadCount:134, urlHash: 'a1', folderId: 3}
|
||||
item2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 2}
|
||||
|
|
|
@ -345,14 +345,21 @@ describe '_Persistence', ->
|
|||
|
||||
it 'should do a proper user settings read show request', =>
|
||||
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
|
||||
pers.userSettingsReadShow()
|
||||
params =
|
||||
onSuccess: ->
|
||||
|
||||
expect(@req.post).toHaveBeenCalledWith('news_usersettings_read_show')
|
||||
pers.userSettingsReadShow(params.onSuccess)
|
||||
|
||||
expect(@req.post).toHaveBeenCalledWith('news_usersettings_read_show',
|
||||
params)
|
||||
|
||||
|
||||
|
||||
it 'should do a proper user settings read hide request', =>
|
||||
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
|
||||
pers.userSettingsReadHide()
|
||||
params =
|
||||
onSuccess: ->
|
||||
pers.userSettingsReadHide(params.onSuccess)
|
||||
|
||||
expect(@req.post).toHaveBeenCalledWith('news_usersettings_read_hide')
|
||||
expect(@req.post).toHaveBeenCalledWith('news_usersettings_read_hide',
|
||||
params)
|
|
@ -42,7 +42,7 @@
|
|||
</div>
|
||||
|
||||
<div class="body"
|
||||
ng-click="setRead(item.id)"
|
||||
ng-click="itemBl.setRead(item.id)"
|
||||
ng-bind-html-unsafe="item.body">
|
||||
</div>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче