-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add my starred classes #121
base: main
Are you sure you want to change the base?
Conversation
Closes #114 |
{image} | ||
</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: why was this removed? what does this look like on dark mode?
|
||
/** List of top filter IDs and their displayed names. */ | ||
const CLASS_FLAGS_1: FilterGroup = [ | ||
["starred", "My starred", <LuStar fill="currentColor" />], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "Starred", no my
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but honestly whatever
|
||
/** List of top filter IDs and their displayed names. */ | ||
const CLASS_FLAGS_1: FilterGroup = [ | ||
["starred", "My starred", <LuStar fill="currentColor" />], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is this where we want this to be? like, before even the "HASS" filter?
seems too important for a feature that i'm not sure will get much usage
i think it should be at least at the end of this row, and possibly even hidden
/** Set of starred class numbers */ | ||
private starredClasses: Set<string> = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this to below the other private fields
|
||
// Load starred classes from storage | ||
const storedStarred = this.store.get("starredClasses"); | ||
if (storedStarred) { | ||
this.starredClasses = new Set(storedStarred); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this to initState
|
||
/** Star or unstar a class */ | ||
toggleStarClass(classNumber: string): void { | ||
if (this.starredClasses.has(classNumber)) { | ||
this.starredClasses.delete(classNumber); | ||
} else { | ||
this.starredClasses.add(classNumber); | ||
} | ||
this.store.set("starredClasses", Array.from(this.starredClasses)); | ||
this.updateState(); | ||
} | ||
|
||
/** Check if a class is starred */ | ||
isClassStarred(classNumber: string): boolean { | ||
return this.starredClasses.has(classNumber); | ||
} | ||
|
||
/** Get all starred classes */ | ||
getStarredClasses(): Class[] { | ||
return Array.from(this.starredClasses) | ||
.map((number) => this.classes.get(number)) | ||
.filter((cls): cls is Class => cls !== undefined); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move these under the state management methods
/** Get all starred classes */ | ||
getStarredClasses(): Class[] { | ||
return Array.from(this.starredClasses) | ||
.map((number) => this.classes.get(number)) | ||
.filter((cls): cls is Class => cls !== undefined); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove unused function
@@ -2,6 +2,7 @@ import { Preferences, Save } from "./schema"; | |||
|
|||
export type TermStore = { | |||
saves: Save[]; | |||
starredClasses: string[]; // Array of class numbers that are starred |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: i kind of wonder whether we should be putting this as under TermStore or GlobalStore, though i think TermStore makes more sense
@@ -2,6 +2,7 @@ import { Preferences, Save } from "./schema"; | |||
|
|||
export type TermStore = { | |||
saves: Save[]; | |||
starredClasses: string[]; // Array of class numbers that are starred |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's use the jsdoc style to comment this
@@ -401,4 +409,27 @@ export class State { | |||
this.loadSave(this.saves[0]!.id); | |||
} | |||
} | |||
|
|||
/** Star or unstar a class */ | |||
toggleStarClass(classNumber: string): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i'm not sure if we want this method to use classNumber
, rather than cls
. all the other methods that take in classes always take them in by class, and classNumber
is nearly always only used for internal representations
Add column in ClassTable to star certain classes, and then you can filter for starred classes