Skip to content

Commit

Permalink
checed subjects
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanromakh committed Aug 15, 2023
1 parent 9676d5f commit 39bc230
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ class AssignmentMobilePage extends Component<PlayProps, PlayState> {
}
return -1;
});

if (classroom.assignments.length > 0) {
console.log('classroom1', classroom)
}
}
// sort
return classrooms.filter(c => c.assignments.length > 0);
Expand All @@ -132,8 +128,7 @@ class AssignmentMobilePage extends Component<PlayProps, PlayState> {
const assignments = await getAssignedBricks();
const subjects = await getSubjects();
if (assignments && subjects) {
let classrooms = this.getClassrooms(assignments);
console.log('classrooms', classrooms)
const classrooms = this.getClassrooms(assignments);
if (activeClassroomId > 0) {
const classroom = classrooms.find(c => c.id === activeClassroomId);
if (classroom) {
Expand Down
16 changes: 9 additions & 7 deletions src/components/viewAllPage/ViewAll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ interface ViewAllState {

const MobileTheme = React.lazy(() => import("./themes/ViewAllPageMobileTheme"));
const TabletTheme = React.lazy(() => import("./themes/ViewAllPageTabletTheme"));
const DesktopTheme = React.lazy(
() => import("./themes/ViewAllPageDesktopTheme")
);
const DesktopTheme = React.lazy(() => import("./themes/ViewAllPageDesktopTheme"));

class ViewAllPage extends Component<ViewAllProps, ViewAllState> {
static animationTimeout = 600;
Expand Down Expand Up @@ -271,7 +269,7 @@ class ViewAllPage extends Component<ViewAllProps, ViewAllState> {
const oldNotifications = prevProps.notifications;
if (notifications && oldNotifications) {
if (notifications.length > oldNotifications.length) {
this.loadBricks();
this.loadBricks(this.state.subjects);
}
}
this.addWheelListener();
Expand Down Expand Up @@ -352,7 +350,7 @@ class ViewAllPage extends Component<ViewAllProps, ViewAllState> {
}

async loadData(values: queryString.ParsedQuery<string>) {
await this.loadSubjects(values);
const subjects = await this.loadSubjects(values);

if (values.searchString) {
let page = 0;
Expand All @@ -364,7 +362,7 @@ class ViewAllPage extends Component<ViewAllProps, ViewAllState> {
if (this.state.subjectGroup) {
this.loadUnauthorizedBricks(this.state.subjectGroup);
} else {
this.loadBricks(values);
this.loadBricks(subjects, values);
}
} else {
if (this.state.subjectGroup) {
Expand Down Expand Up @@ -409,13 +407,17 @@ class ViewAllPage extends Component<ViewAllProps, ViewAllState> {
);
}

async loadBricks(values?: queryString.ParsedQuery<string>) {
async loadBricks(subjects: SubjectItem[] | null, values?: queryString.ParsedQuery<string>) {
if (this.props.user) {
let subjectIds: number[] = [];
const {state} = this;
if (state.isAllSubjects == false) {
subjectIds = this.props.user.subjects.map(s => s.id);
} else {
let checked = subjects?.filter(s => s.checked);
subjectIds = checked ? checked.map(s => s.id) : [];
}

const pageBricks = await getPublishedBricksByPage(
state.pageSize, state.page, true,
state.filterLevels, state.filterLength, subjectIds,
Expand Down

0 comments on commit 39bc230

Please sign in to comment.