Skip to content

Commit

Permalink
Fix bug where histories cannot be loaded during colab session
Browse files Browse the repository at this point in the history
Fix interfaces to be more correct.
  • Loading branch information
LimZiJia committed Nov 12, 2024
1 parent 4475d8c commit e1218cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions frontend/src/_services/history.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class HistoryService extends ApiService {
difficulty: item.question.difficulty,
status: item.status,
time: item.createdAt,
language: item.snapshot.language,
code: item.snapshot.code,
language: item.snapshot?.language,
code: item.snapshot?.code,
})),
),
);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/account/history/history.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ <h4>{{ history?.question }}</h4>
<div #editor class="editor-content"></div>
</div>
</div>
<p-toast position="bottom-right" [breakpoints]="{ '920px': { width: '90%' } }" />
12 changes: 10 additions & 2 deletions frontend/src/app/account/history/history.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { oneDark } from '@codemirror/theme-one-dark';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from 'codemirror';
import { languageMap } from '../../collaboration/editor/languages';
import { ToastModule } from 'primeng/toast';

@Component({
standalone: true,
imports: [TableModule, CommonModule, InputTextModule, ButtonModule, IconFieldModule, InputIconModule],
imports: [TableModule, CommonModule, InputTextModule, ButtonModule, IconFieldModule, InputIconModule, ToastModule],
providers: [MessageService, DatePipe],
templateUrl: './history.component.html',
styleUrl: './history.component.css',
Expand Down Expand Up @@ -43,7 +44,6 @@ export class HistoryComponent implements OnInit {
time: this.datePipe.transform(history.time, 'short'), // Pipe to format date for searching
}));
this.loading = false;
console.log(this.histories);
},
error: () => {
this.histories = [];
Expand All @@ -63,6 +63,14 @@ export class HistoryComponent implements OnInit {
this.isPanelVisible = true;
if (history.code && history.language) {
this.initializeEditor(history.code, history.language);
} else {
console.log("why no message?")

Check failure on line 67 in frontend/src/app/account/history/history.component.ts

View workflow job for this annotation

GitHub Actions / build-service (frontend)

Replace `"why·no·message?")` with `'why·no·message?');`
this.messageService.add({
severity: 'warn',
summary: 'Code Not Found',
detail: 'Your colaboration session might not have ended',
life: 3000,
});
}
}

Expand Down
10 changes: 5 additions & 5 deletions frontend/src/app/account/history/history.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export interface MatchingHistory {
topics: string[]; // question topics
status: statusValues; // status of the session
time: string | null; // time of the session
language: string | null; // language used during the session
code: string | null; // code written during the session
language: string | undefined; // language used during the session
code: string | undefined; // code written during the session
}

export interface User {
Expand All @@ -33,8 +33,8 @@ export interface Question {
}

export interface Snapshot {
language: string | null;
code: string | null;
language: string;
code: string;
}

export interface sessionHistory {
Expand All @@ -46,7 +46,7 @@ export interface sessionHistory {
status: statusValues;
createdAt: string;
updatedAt: string;
snapshot: Snapshot;
snapshot?: Snapshot;
}

export interface historyResponse {
Expand Down

0 comments on commit e1218cc

Please sign in to comment.