Skip to content

Commit

Permalink
fix linteer
Browse files Browse the repository at this point in the history
  • Loading branch information
mono424 committed Sep 14, 2023
1 parent 09105a4 commit df179a7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
17 changes: 13 additions & 4 deletions web/ts/api/admin-lecture-list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import {del, get, patch, post, postFormData, PostFormDataListener, put, uploadFile} from "../utilities/fetch-wrappers";
import {
del,
get,
patch,
post,
postFormData,
PostFormDataListener,
put,
uploadFile,
} from "../utilities/fetch-wrappers";
import { StatusCodes } from "http-status-codes";

export interface UpdateLectureMetaRequest {
Expand Down Expand Up @@ -83,11 +92,11 @@ export type VideoSection = {
fileID?: number;
};

export function videoSectionTimestamp(a: VideoSection) : number {
export function videoSectionTimestamp(a: VideoSection): number {
return a.startHours * 3600 + a.startMinutes * 60 + a.startSeconds;
}

export function videoSectionSort(a: VideoSection, b: VideoSection) : number {
export function videoSectionSort(a: VideoSection, b: VideoSection): number {
return videoSectionTimestamp(a) - videoSectionTimestamp(b);
}

Expand Down Expand Up @@ -212,7 +221,7 @@ export const AdminLectureList = {
* @param courseId
* @param lectureId
*/
saveSeriesMetadata: async (courseId: number, lectureId: number): Promise<void> => {
saveSeriesMetadata: async (courseId: number, lectureId: number): Promise<void> => {
await post(`/api/course/${courseId}/updateLectureSeries/${lectureId}`);
},

Expand Down
22 changes: 11 additions & 11 deletions web/ts/edit-course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
LectureVideoTypeCam,
LectureVideoTypeComb,
LectureVideoTypePres,
LectureVideoTypes, VideoSection, videoSectionSort,
LectureVideoTypes,
VideoSection,
videoSectionSort,
} from "./api/admin-lecture-list";
import {ChangeSet, comparatorPipeline, ignoreKeys, singleProperty} from "./change-set";
import { ChangeSet, comparatorPipeline, ignoreKeys, singleProperty } from "./change-set";
import { AlpineComponent } from "./components/alpine-component";

export enum UIEditMode {
Expand Down Expand Up @@ -116,11 +118,11 @@ export function lectureEditor(lecture: Lecture): AlpineComponent {
init() {
const customComparator = comparatorPipeline([
ignoreKeys(["files"]),
singleProperty("videoSections", (a: Lecture, b: Lecture): boolean|null => {
singleProperty("videoSections", (a: Lecture, b: Lecture): boolean | null => {
if (a.videoSections.length !== b.videoSections.length) {
return true;
}
if (a.videoSections.some(({ id }) => !b.videoSections.some(({id: bId}) => id === bId))) {
if (a.videoSections.some(({ id }) => !b.videoSections.some(({ id: bId }) => id === bId))) {
return true;
}
}),
Expand Down Expand Up @@ -204,16 +206,14 @@ export function lectureEditor(lecture: Lecture): AlpineComponent {
},

addSection(section: VideoSection) {
this.changeSet.patch("videoSections", [
...this.lectureData.videoSections,
section,
].sort(videoSectionSort));
this.changeSet.patch("videoSections", [...this.lectureData.videoSections, section].sort(videoSectionSort));
},

deleteSection(id: number) {
this.changeSet.patch("videoSections", this.lectureData.videoSections.filter(
(s) => s.id !== id,
));
this.changeSet.patch(
"videoSections",
this.lectureData.videoSections.filter((s) => s.id !== id),
);
},

isValidVideoSection(section: VideoSection): boolean {
Expand Down
2 changes: 1 addition & 1 deletion web/ts/entry/admins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export * from "../courseAdminManagement";
export * from "../notification-management";
export * from "../audits";
export * from "../maintenance";
export * from "../change-set"
export * from "../change-set";
export { VideoSectionsAdminController, VideoSectionUpdater } from "../video-sections";
9 changes: 6 additions & 3 deletions web/ts/utilities/fetch-wrappers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {postFormData} from "../global";
import { postFormData } from "../global";

/**
* Wrapper for Javascript's fetch function for GET
Expand Down Expand Up @@ -44,7 +44,6 @@ export async function post(url: string, body: object = {}) {
});
}


export interface PostFormDataListener {
onProgress?: (progress: number) => void;
}
Expand All @@ -56,7 +55,11 @@ export interface PostFormDataListener {
* @param {PostFormDataListener} listener attached progress listeners
* @return {Promise<XMLHttpRequest>}
*/
export function postFormData(url: string, body: FormData, listener: PostFormDataListener = {}): Promise<XMLHttpRequest> {
export function postFormData(
url: string,
body: FormData,
listener: PostFormDataListener = {},
): Promise<XMLHttpRequest> {
const xhr = new XMLHttpRequest();
return new Promise((resolve, reject) => {
xhr.onloadend = () => {
Expand Down

0 comments on commit df179a7

Please sign in to comment.