Fix a bug that would mark the items on the right side as read regardless of feed or folder id

This commit is contained in:
Bernhard Posselt 2013-05-09 14:03:37 +02:00
Родитель 59069e85a2
Коммит 019b286b8e
7 изменённых файлов: 60 добавлений и 22 удалений

Просмотреть файл

@ -9,6 +9,8 @@ ownCloud-news (0.99)
* Make only one http request for reading all items and all items of a folder
* Fix bug that would prevent marking a feed as read when its created and no other feeds are there
* Fix bug that would prevent readding of a feed when a folder containing the feed was deleted
* Also send newest item id in the api when creating a feed
* Fix a bug that would mark the items on the right side as read regardless of feed or folder id
ownCloud-news (0.98)

Просмотреть файл

@ -70,9 +70,10 @@ FeedModel, NewLoading, _ExistsError, Utils, $rootScope, UndoQueue, NewestItem)->
if angular.isDefined(feed) and newestItemId != 0
feed.unreadCount = 0
@_persistence.setFeedRead(feedId, newestItemId)
for item in @_itemModel.getAll()
item.setRead()
if item.feedId == feed.id
item.setRead()
@_persistence.setFeedRead(feedId, newestItemId)
getNumberOfFeeds: ->

Просмотреть файл

@ -89,8 +89,12 @@ NewestItem, FeedModel) ->
if newestItemId != 0 and angular.isDefined(folder)
for feed in @_feedBusinessLayer.getFeedsOfFolder(folderId)
feed.unreadCount = 0
for item in @_itemModel.getAll()
item.setRead()
# also set items in feeds as read
for item in @_itemModel.getAll()
if item.feedId == feed.id
item.setRead()
@_persistence.setFolderRead(folderId, newestItemId)

Просмотреть файл

@ -860,20 +860,20 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
};
FeedBusinessLayer.prototype.markRead = function(feedId) {
var feed, item, newestItemId, _i, _len, _ref, _results;
var feed, item, newestItemId, _i, _len, _ref;
feed = this._feedModel.getById(feedId);
newestItemId = this._newestItem.getId();
if (angular.isDefined(feed) && newestItemId !== 0) {
feed.unreadCount = 0;
this._persistence.setFeedRead(feedId, newestItemId);
_ref = this._itemModel.getAll();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_results.push(item.setRead());
if (item.feedId === feed.id) {
item.setRead();
}
}
return _results;
return this._persistence.setFeedRead(feedId, newestItemId);
}
};
@ -1139,11 +1139,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
feed = _ref[_i];
feed.unreadCount = 0;
}
_ref1 = this._itemModel.getAll();
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
item = _ref1[_j];
item.setRead();
_ref1 = this._itemModel.getAll();
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
item = _ref1[_j];
if (item.feedId === feed.id) {
item.setRead();
}
}
}
return this._persistence.setFolderRead(folderId, newestItemId);
}

Просмотреть файл

@ -94,6 +94,7 @@ describe 'FeedBusinessLayer', ->
it 'should not mark feed read when no highest item id', =>
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedBusinessLayer.markRead(5)
expect(@persistence.setFeedRead).not.toHaveBeenCalled()
@ -103,17 +104,22 @@ describe 'FeedBusinessLayer', ->
@NewestItem.handle(25)
@ActiveFeed.handle({type: @FeedType.Feed, id: 5})
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
@ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'})
@ItemModel.add({id: 3, feedId: 5, guidHash: 'a2'})
@ItemModel.add({id: 2, feedId: 5, guidHash: 'a3'})
item1 = {id: 3, feedId: 5, guidHash: 'a3', status: 0}
@ItemModel.add(item1)
item1.setUnread()
item2 = {id: 2, feedId: 3, guidHash: 'a3', status: 0}
@ItemModel.add(item2)
item2.setUnread()
@FeedBusinessLayer.markRead(5)
expect(@persistence.setFeedRead).toHaveBeenCalledWith(5, 25)
expect(@FeedModel.getById(5).unreadCount).toBe(0)
expect(@ItemModel.getById(6).isRead()).toBeTruthy()
expect(@ItemModel.getById(3).isRead()).toBeTruthy()
expect(@ItemModel.getById(2).isRead()).toBeTruthy()
expect(item1.isRead()).toBe(true)
expect(item2.isRead()).toBe(false)
it 'should get the correct unread count for subscribtions', =>

Просмотреть файл

@ -40,7 +40,7 @@ describe 'FolderBusinessLayer', ->
beforeEach inject (@FolderBusinessLayer, @FolderModel, @FeedModel, @ShowAll,
@ActiveFeed, @FeedType, @_ExistsError, @$timeout,
@NewestItem) =>
@NewestItem, @ItemModel) =>
@ShowAll.setShowAll(false)
@ActiveFeed.handle({type: @FeedType.Feed, id:0})
@ -88,9 +88,17 @@ describe 'FolderBusinessLayer', ->
it 'should mark folder as read', =>
@NewestItem.handle(25)
@FolderModel.add({id: 3, opened: false, name: 'ho'})
@persistence.setFolderRead = jasmine.createSpy('setFeedRead')
item1 = {id: 3, feedId: 5, guidHash: 'a3', status: 0}
@ItemModel.add(item1)
item1.setUnread()
item2 = {id: 2, feedId: 3, guidHash: 'a3', status: 0}
@ItemModel.add(item2)
item2.setUnread()
@FolderModel.add({id: 3, opened: false, name: 'ho'})
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, url: 'a1'})
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a2'})
@FeedModel.add({id: 1, unreadCount:12, folderId: 3, url: 'a3'})
@ -101,9 +109,19 @@ describe 'FolderBusinessLayer', ->
expect(@FeedModel.getById(1).unreadCount).toBe(0)
expect(@FeedModel.getById(5).unreadCount).toBe(2)
expect(item1.isRead()).toBe(false)
expect(item2.isRead()).toBe(true)
expect(@persistence.setFolderRead).toHaveBeenCalledWith(3, 25)
it 'should not mark folder read when no highest item id', =>
@FolderModel.add({id: 5, opened: false, name: 'ho'})
@persistence.setFolderRead = jasmine.createSpy('setFolderRead')
@FolderBusinessLayer.markRead(5)
expect(@persistence.setFolderRead).not.toHaveBeenCalled()
it 'should get the correct unread count', =>
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'})
@FeedModel.add({id: 6, unreadCount:3, folderId: 3, url: 'a2'})

Просмотреть файл

@ -83,6 +83,11 @@ describe 'SubscriptionsBusinessLayer', ->
expect(@persistence.setAllRead).toHaveBeenCalledWith(25)
it 'should not mark all read when no highest item id', =>
@persistence.setAllRead = jasmine.createSpy('setAllRead')
@SubscriptionsBusinessLayer.markRead()
expect(@persistence.setAllRead).not.toHaveBeenCalled()
it 'should get the correct unread count', =>
@FeedModel.add({id: 3, unreadCount: 132, url: 'hoho'})
@FeedModel.add({id: 4, unreadCount: 12, url: 'hohod'})