blob: 1af22ea5c41e1458d0ce8e23c3123c575626a9a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/**
* ownCloud - News
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.controller('ContentController',
function (Publisher, FeedResource, ItemResource, SettingsResource, data,
$route, $routeParams) {
'use strict';
// dont cache items across multiple route changes
ItemResource.clear();
// distribute data to models based on key
Publisher.publishAll(data);
this.isAutoPagingEnabled = true;
this.getItems = () => {
return ItemResource.getAll();
};
this.toggleStar = (itemId) => {
ItemResource.toggleStar(itemId);
};
this.markRead = (itemId) => {
let item = ItemResource.get(itemId);
if (!item.keepUnread) {
ItemResource.markItemRead(itemId);
FeedResource.markItemOfFeedRead(item.feedId);
}
};
this.getFeed = (feedId) => {
return FeedResource.getById(feedId);
};
this.toggleKeepUnread = (itemId) => {
let item = ItemResource.get(itemId);
if (!item.unread) {
FeedResource.markItemOfFeedUnread(item.feedId);
ItemResource.markItemRead(itemId, false);
}
item.keepUnread = !item.keepUnread;
};
this.orderBy = () => {
if (SettingsResource.get('oldestFirst')) {
return '-id';
} else {
return 'id';
}
};
this.isCompactView = () => {
return SettingsResource.get('compact');
};
this.autoPagingEnabled = () => {
return this.isAutoPagingEnabled;
};
this.markReadEnabled = () => {
return !SettingsResource.get('preventReadOnScroll');
};
this.scrollRead = (itemIds) => {
let ids = [];
for (let itemId of itemIds) {
let item = ItemResource.get(itemId);
if (!item.keepUnread) {
ids.push(itemId);
FeedResource.markItemOfFeedRead(item.feedId);
}
}
ItemResource.markItemsRead(ids);
};
this.autoPage = () => {
this.isAutoPagingEnabled = false;
let type = $route.current.$$route.type;
let id = $routeParams.id;
ItemResource.autoPage(type, id).success((data) => {
Publisher.publishAll(data);
if (data.items.length > 0) {
this.isAutoPagingEnabled = true;
}
}).error(() => {
this.isAutoPagingEnabled = true;
});
};
this.getRelativeDate = (timestamp) => {
if (timestamp !== undefined && timestamp !== '') {
let languageCode = SettingsResource.get('language');
return moment.unix(timestamp).lang(languageCode).fromNow();
} else {
return '';
}
};
});
|