Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/app/home/course/course.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ export class CoursePage implements OnInit, AfterViewInit, OnDestroy {
duration: 0
};
this.lastPlayedVideoKey = Object.values(history).map(h => h.video_id).sort((a, b) => {
// force history[b].updated_at to be a string
// force history[b].played_at to be a string
// @ts-ignore
return ('' + history[b].updated_at).localeCompare(history[a].updated_at);
return ('' + history[b].played_at).localeCompare(history[a].played_at);
}).slice(0, 1)[0] ?? null;
const videoInfo = Object.values(videos).map(lecture => {
lecture.history = history[lecture.id] ?? ((lecture.id in evaluations && lecture.duration) ? { // If evaluation exists, treat as watched
end_time: lecture.duration,
updated_at: null,
} : {end_time: null, updated_at: null});
played_at: null,
} : {end_time: null, played_at: null});
if (lecture.duration) {
progress.duration -= -lecture.duration;
if (lecture.history.end_time) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/man.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class ManService {
const records = data?.records ?? {};
if (update) {
if (!records[update.video_id] ||
(records[update.video_id].updated_at < update.updated_at)) {
(records[update.video_id].played_at < update.played_at)) {
records[update.video_id] = update;
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ export interface CourseListResponse {
}[];
};
last_fetched_at: string;
last_played: { video: Lecture, updated_at: string, end_time: number } | null;
last_played: { video: Lecture, played_at: string, end_time: number } | null;
}

export interface EvaluationRecord {
Expand Down
4 changes: 2 additions & 2 deletions src/app/play-tracker.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {inject, Injectable} from '@angular/core';
import {first, map, mergeMap, switchMap, tap} from 'rxjs/operators';
import {first, map, switchMap, tap} from 'rxjs/operators';
import {fromEventPattern, Observable} from 'rxjs';
import {FieldValue, Timestamp} from '@angular/fire/firestore';
import Pusher from 'pusher-js';
Expand Down Expand Up @@ -61,7 +61,7 @@ export interface PlayHistory {
export interface PlayHistoryValue {
duration?: number | null;
end_time: number;
updated_at: Timestamp | FieldValue;
played_at: Timestamp | FieldValue;
video_id?: number;
year?: string;
course?: string;
Expand Down