Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

snowmonkey18
Copy link
Contributor

@snowmonkey18 snowmonkey18 commented Jan 22, 2025

Add column in ClassTable to star certain classes, and then you can filter for starred classes

@snowmonkey18 snowmonkey18 changed the title Add my starred classes [in progress]Add my starred classes Jan 22, 2025
@snowmonkey18 snowmonkey18 changed the title [in progress]Add my starred classes Add my starred classes Jan 22, 2025
@dtemkin1 dtemkin1 requested review from dtemkin1 and psvenk January 22, 2025 16:27
@dtemkin1
Copy link
Collaborator

dtemkin1 commented Jan 22, 2025

Closes #114

Comment on lines +313 to +314
{image}
</Button>
Copy link
Member

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" />],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "Starred", no my

Copy link
Member

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" />],
Copy link
Member

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

Comment on lines +26 to +27
/** Set of starred class numbers */
private starredClasses: Set<string> = new Set();
Copy link
Member

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

Comment on lines +73 to +78

// Load starred classes from storage
const storedStarred = this.store.get("starredClasses");
if (storedStarred) {
this.starredClasses = new Set(storedStarred);
}
Copy link
Member

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

Comment on lines +412 to +434

/** 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);
}
Copy link
Member

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

Comment on lines +429 to +434
/** Get all starred classes */
getStarredClasses(): Class[] {
return Array.from(this.starredClasses)
.map((number) => this.classes.get(number))
.filter((cls): cls is Class => cls !== undefined);
}
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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 {
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants