Skip to content

Commit

Permalink
fix: duplicate video subject bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Okabe-Rintarou-0 committed Jun 11, 2024
1 parent 97de08d commit 6957cde
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sjtu_canvas_helper"
version = "1.3.8"
version = "1.3.9"
description = "SJTU Canvas Helper"
authors = ["Okabe"]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "SJTU Canvas Helper",
"version": "1.3.8"
"version": "1.3.9"
},
"tauri": {
"allowlist": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/change_log_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function ChangeLogModal({ open, onCancel, onOk }: {
overflow: "scroll",
}}>
<Typography>
<Title level={4}>v1.3.8 2024/6/11</Title>
<Title level={4}>v1.3.8, v1.3.9 2024/6/11</Title>
<Paragraph>
<ul>
<li>[Fix] 修复视屏播放重名课程导致的 UI bug。 </li>
Expand Down
15 changes: 13 additions & 2 deletions src/page/video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ export default function VideoPage() {
const handleGetSubjects = async () => {
try {
const subjects = await invoke("get_subjects") as Subject[];
setSubjects(subjects);
const subjectIdSet = new Set<number>();
for (let subject of subjects) {
subjectIdSet.add(subject.subjectId);
}
setSubjects(subjects.filter(subject => {
if (subjectIdSet.has(subject.subjectId)) {
subjectIdSet.delete(subject.subjectId);
return true;
} else {
return false;
}
}));
return true;
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -354,7 +365,7 @@ export default function VideoPage() {
style={{ width: 350 }}
onChange={handleSelectSubject}
options={subjects.map(subject => ({
label: `${subject.subjectName}(${subject.classroomName}, id: ${subject.subjectId})`,
label: `${subject.subjectName}(${subject.classroomName})`,
value: subject.subjectId,
}))}
/>
Expand Down

0 comments on commit 6957cde

Please sign in to comment.