diff --git a/app/manifest.json b/app/manifest.json index 95d4053..b6a73f1 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_appName__", "short_name": "__MSG_appShortName__", - "version": "2.2.1", + "version": "2.2.3", "manifest_version": 2, "description": "__MSG_appDescription__", "icons": { diff --git a/app/scripts/src/history-sync/components/activity-list-item.js b/app/scripts/src/history-sync/components/activity-list-item.js index 4abecf4..65d8dff 100644 --- a/app/scripts/src/history-sync/components/activity-list-item.js +++ b/app/scripts/src/history-sync/components/activity-list-item.js @@ -35,23 +35,20 @@ export default class ActivityListItem extends React.Component { nrkTitle += " (S"+nrk.season+"E"+nrk.episode+")"; } let nrkUrl = `https://tv.nrk.no/program/${nrk.id}`; - let traktArray = activity.trakt; + let trakt = activity.trakt; let traktDate, traktUrl, traktTitle; - if (traktArray) { - traktArray.forEach((trakt, index)=> { - if (index === 0){ - traktDate = trakt.date ? trakt.date.format('MMMM Do YYYY, HH:mm:ss') : '-'; - traktUrl = trakt.season ? `https://trakt.tv/shows/${trakt.show.ids.slug}/seasons/${trakt.season}/episodes/${trakt.number}` : `https://trakt.tv/movies/${trakt.ids.slug}`; - if (trakt.show && trakt.title){ - traktTitle = `${trakt.show.title}: ${trakt.title}`; - } else { - traktTitle = trakt.show ? trakt.show.title : trakt.title; - } - } else { - traktDate += " & " + (trakt.date ? trakt.date.format('MMMM Do YYYY, HH:mm:ss') : '-'); - } - }) + if (trakt) { + trakt.dates.forEach((date, index) => { + const readableDate = date.format('MMMM Do YYYY, HH:mm:ss'); + (index === 0) ? (traktDate = readableDate) : (traktDate += " & " + readableDate); + }); + traktUrl = trakt.season ? `https://trakt.tv/shows/${trakt.show.ids.slug}/seasons/${trakt.season}/episodes/${trakt.number}` : `https://trakt.tv/movies/${trakt.ids.slug}`; + if (trakt.show && trakt.title){ + traktTitle = `${trakt.show.title}: ${trakt.title}`; + } else { + traktTitle = trakt.show ? trakt.show.title : trakt.title; + } } let formId = `${nrk.id}--add`; @@ -61,7 +58,7 @@ export default class ActivityListItem extends React.Component { diff --git a/app/scripts/src/history-sync/utils/trakt-web-api-utils.js b/app/scripts/src/history-sync/utils/trakt-web-api-utils.js index 33a0bf4..ef8baf9 100644 --- a/app/scripts/src/history-sync/utils/trakt-web-api-utils.js +++ b/app/scripts/src/history-sync/utils/trakt-web-api-utils.js @@ -63,7 +63,7 @@ export default class TraktWebAPIUtils { }) .catch((status, response) => { let nrk = Object.assign(options.item, { date: options.date }); - resolve(Object.assign({ nrk, trakt: [] }, { add: false })); + resolve(Object.assign({ nrk }, { add: false })); }); }); } @@ -76,18 +76,18 @@ export default class TraktWebAPIUtils { success: function(response) { let exclude = false; let allHistory = JSON.parse(response); - let trakt = []; + let dates = []; allHistory.forEach((history) => { - let date; if (history && history.watched_at) { - date = moment(history.watched_at); + const date = moment(history.watched_at); exclude = exclude || date.diff(options.result.date, 'days') == 0; + dates.push(date.clone()); } - trakt.push(Object.assign({}, options.result.activity, {date: date.clone()})); }); - let nrk = Object.assign(options.item, {date: options.date}); + let trakt = Object.assign(options.result.activity, { dates: dates }); + let nrk = Object.assign(options.item, { date: options.date }); exclude = exclude || (options.item.progress.percentageWatched < options.item.progress.percentageAssumedFinished); resolve(Object.assign({ nrk, trakt }, { add: !exclude }));