Frontend code cleanup

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-09-07 13:08:18 +02:00
parent 4441075f49
commit df4f8dda60
2 changed files with 18 additions and 16 deletions

View File

@@ -20,7 +20,7 @@
* *
*/ */
/* global OC */ /* global OC OCA */
class ActivityController { class ActivityController {
constructor ($scope, CardService, ActivityService) { constructor ($scope, CardService, ActivityService) {

View File

@@ -49,10 +49,10 @@ class ActivityService {
static getUrl(type, id, since) { static getUrl(type, id, since) {
if (type === DECK_ACTIVITY_TYPE_CARD) { if (type === DECK_ACTIVITY_TYPE_CARD) {
return OC.linkToOCS('apps/activity/api/v2/activity', 2) + 'filter?format=json&object_type=deck_card&object_id=' + id + '&limit=5&since=' + since; return OC.linkToOCS('apps/activity/api/v2/activity', 2) + 'filter?format=json&object_type=deck_card&object_id=' + id + '&limit=50&since=' + since;
} }
if (type === DECK_ACTIVITY_TYPE_BOARD) { if (type === DECK_ACTIVITY_TYPE_BOARD) {
return OC.linkToOCS('apps/activity/api/v2/activity', 2) + 'deck?format=json&limit=5&since=' + since; return OC.linkToOCS('apps/activity/api/v2/activity', 2) + 'deck?format=json&limit=50&since=' + since;
} }
} }
@@ -60,7 +60,7 @@ class ActivityService {
this.running = true; this.running = true;
this.checkData(type, id); this.checkData(type, id);
var self = this; const self = this;
return this.$http.get(ActivityService.getUrl(type, id, since)).then(function (response) { return this.$http.get(ActivityService.getUrl(type, id, since)).then(function (response) {
const objects = response.data.ocs.data; const objects = response.data.ocs.data;
@@ -111,17 +111,19 @@ class ActivityService {
} }
addItem(type, id, item) { addItem(type, id, item) {
if (this.data[type][id].findIndex((entry) => { return entry.activity_id === item.activity_id; }) === -1) { const existingEntry = this.data[type][id].findIndex((entry) => { return entry.activity_id === item.activity_id; });
if (type === DECK_ACTIVITY_TYPE_BOARD && ( if (existingEntry !== -1) {
(item.object_type === DECK_ACTIVITY_TYPE_CARD && item.subject_rich[1].board && item.subject_rich[1].board.id !== id) return;
|| (item.object_type === DECK_ACTIVITY_TYPE_BOARD && item.object_id !== id) }
)) { /** check if the fetched item from all deck activities is actually related */
const isUnrelatedBoard = (item.object_type === DECK_ACTIVITY_TYPE_BOARD && item.object_id !== id);
const isUnrelatedCard = (item.object_type === DECK_ACTIVITY_TYPE_CARD && item.subject_rich[1].board && item.subject_rich[1].board.id !== id);
if (type === DECK_ACTIVITY_TYPE_BOARD && (isUnrelatedBoard || isUnrelatedCard)) {
return; return;
} }
item.timestamp = new Date(item.datetime).getTime(); item.timestamp = new Date(item.datetime).getTime();
this.data[type][id].push(item); this.data[type][id].push(item);
} }
}
/** /**
* Fetch newer activities starting from the latest ones that are in cache * Fetch newer activities starting from the latest ones that are in cache
@@ -140,12 +142,12 @@ class ActivityService {
} }
fetchNewer(type, id) { fetchNewer(type, id) {
var deferred = this.$q.defer(); const deferred = this.$q.defer();
this.running = true; this.running = true;
this.runningNewer = true; this.runningNewer = true;
var self = this; const self = this;
this.$http.get(ActivityService.getUrl(type, id, this.since[type][id].latest) + '&sort=asc').then(function (response) { this.$http.get(ActivityService.getUrl(type, id, this.since[type][id].latest) + '&sort=asc').then(function (response) {
var objects = response.data.ocs.data; let objects = response.data.ocs.data;
let data = []; let data = [];
for (let index in objects) { for (let index in objects) {