Skip to content

Commit

Permalink
- More bugfixes with history sync
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMamen committed Sep 10, 2018
1 parent 3e16060 commit f6d7457
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
29 changes: 13 additions & 16 deletions app/scripts/src/history-sync/components/activity-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -61,7 +58,7 @@ export default class ActivityListItem extends React.Component {
<span className='mdl-list__item-primary-content'>
<TmdbImage
className='mdl-list__item-avatar'
item={traktArray[0]}
item={trakt}
imageHost={this.props.imageHost}
imageWidth={this.props.imageWidth}
/>
Expand Down
12 changes: 6 additions & 6 deletions app/scripts/src/history-sync/utils/trakt-web-api-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
});
});
}
Expand All @@ -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 }));
Expand Down

0 comments on commit f6d7457

Please sign in to comment.