зеркало из https://github.com/nextcloud/news.git
hide suggestions from explore if they are already in your feed list
This commit is contained in:
Родитель
5cc1be3a01
Коммит
1246c296cb
|
@ -454,11 +454,15 @@ app.controller('ContentController',
|
|||
};
|
||||
|
||||
}]);
|
||||
app.controller('ExploreController', ["sites", "$rootScope", function (sites, $rootScope) {
|
||||
app.controller('ExploreController', ["sites", "$rootScope", "FeedResource", function (sites, $rootScope, FeedResource) {
|
||||
'use strict';
|
||||
|
||||
this.sites = sites;
|
||||
|
||||
this.feedExists = function (url) {
|
||||
return FeedResource.get(url) !== undefined;
|
||||
};
|
||||
|
||||
this.subscribeTo = function (url) {
|
||||
$rootScope.$broadcast('addFeed', url);
|
||||
};
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -7,11 +7,15 @@
|
|||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.controller('ExploreController', function (sites, $rootScope) {
|
||||
app.controller('ExploreController', function (sites, $rootScope, FeedResource) {
|
||||
'use strict';
|
||||
|
||||
this.sites = sites;
|
||||
|
||||
this.feedExists = function (url) {
|
||||
return FeedResource.get(url) !== undefined;
|
||||
};
|
||||
|
||||
this.subscribeTo = function (url) {
|
||||
$rootScope.$broadcast('addFeed', url);
|
||||
};
|
||||
|
|
|
@ -14,7 +14,18 @@ describe('ExploreController', function () {
|
|||
scope,
|
||||
sites;
|
||||
|
||||
beforeEach(module('News'));
|
||||
beforeEach(module('News', function ($provide) {
|
||||
$provide.constant('BASE_URL', 'base');
|
||||
$provide.constant('ITEM_BATCH_SIZE', 5);
|
||||
$provide.constant('ITEM_AUTO_PAGE_SIZE', 1);
|
||||
$provide.constant('FEED_TYPE', {
|
||||
FEED: 0,
|
||||
FOLDER: 1,
|
||||
STARRED: 2,
|
||||
SUBSCRIPTIONS: 3,
|
||||
SHARED: 4
|
||||
});
|
||||
}));
|
||||
|
||||
beforeEach(inject(function ($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
|
@ -41,4 +52,12 @@ describe('ExploreController', function () {
|
|||
expect(scope.$broadcast).toHaveBeenCalledWith('addFeed', 'test');
|
||||
}));
|
||||
|
||||
|
||||
it('should check if a feed is available sites', inject(
|
||||
function (FeedResource) {
|
||||
FeedResource.add({id: 3, url: 'test'});
|
||||
expect(controller.feedExists('test')).toBe(true);
|
||||
expect(controller.feedExists('amen')).toBe(false);
|
||||
}));
|
||||
|
||||
});
|
|
@ -5,7 +5,7 @@
|
|||
<h2>{{ category }}</h2>
|
||||
|
||||
<ul>
|
||||
<li ng-repeat="entry in data | orderBy:'-votes'">
|
||||
<li ng-repeat="entry in data | orderBy:'-votes'" ng-if="!Explore.feedExists(entry.url)">
|
||||
<h3 ng-show="entry.favicon"
|
||||
ng-style="{ backgroundImage: 'url(' + entry.favicon + ')'}">
|
||||
{{ entry.title }}
|
||||
|
|
Загрузка…
Ссылка в новой задаче