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

Migrate to Redux Toolkit part 9 #2989

Merged
merged 17 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/commons/achievement/AchievementOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { AchievementUser } from 'src/features/achievement/AchievementTypes';

import { fetchTotalXp, fetchTotalXpAdmin } from '../application/actions/SessionActions';
import SessionActions from '../application/actions/SessionActions';
import { useTypedSelector } from '../utils/Hooks';
import AchievementLevel from './overview/AchievementLevel';

Expand All @@ -20,9 +20,9 @@ const AchievementOverview: React.FC<Props> = ({ name, userState }) => {
useEffect(() => {
// If user is student, fetch assessment details from assessment route instead, as seen below
if (crid && crid !== userCrid) {
dispatch(fetchTotalXpAdmin(crid));
dispatch(SessionActions.fetchTotalXpAdmin(crid));
} else {
dispatch(fetchTotalXp());
dispatch(SessionActions.fetchTotalXp());
}
}, [crid, userCrid, dispatch]);

Expand Down
12 changes: 4 additions & 8 deletions src/commons/achievement/AchievementView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import {
getAbilityGlow
} from '../../features/achievement/AchievementConstants';
import { AchievementStatus, AchievementUser } from '../../features/achievement/AchievementTypes';
import {
fetchAssessment,
fetchAssessmentAdmin,
fetchAssessmentOverviews
} from '../application/actions/SessionActions';
import SessionActions from '../application/actions/SessionActions';
import { Assessment } from '../assessment/AssessmentTypes';
import { useTypedSelector } from '../utils/Hooks';
import AchievementCommentCard from './AchievementCommentCard';
Expand All @@ -40,17 +36,17 @@ const AchievementView: React.FC<Props> = ({ focusUuid, userState }) => {

const dispatch = useDispatch();
useEffect(() => {
dispatch(fetchAssessmentOverviews());
dispatch(SessionActions.fetchAssessmentOverviews());
if (!assessmentId) {
return;
}
if (isAdminView) {
// Fetch selected user's assessment from admin route
// Safe to use non-null assertion (refer to `isAdminView` declaration above)
dispatch(fetchAssessmentAdmin(assessmentId, courseRegId!));
dispatch(SessionActions.fetchAssessmentAdmin(assessmentId, courseRegId!));
} else {
// If user is student, fetch assessment details from assessment route instead, as seen below
dispatch(fetchAssessment(assessmentId));
dispatch(SessionActions.fetchAssessment(assessmentId));
}
}, [dispatch, assessmentId, courseRegId, isAdminView]);

Expand Down
4 changes: 2 additions & 2 deletions src/commons/application/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import NavigationBar from '../navigationBar/NavigationBar';
import Constants from '../utils/Constants';
import { useLocalStorageState, useSession } from '../utils/Hooks';
import { defaultWorkspaceSettings, WorkspaceSettingsContext } from '../WorkspaceSettingsContext';
import { fetchUserAndCourse } from './actions/SessionActions';
import SessionActions from './actions/SessionActions';

const Application: React.FC = () => {
const dispatch = useDispatch();
Expand All @@ -26,7 +26,7 @@ const Application: React.FC = () => {
// if the user was previously logged in
React.useEffect(() => {
if (isLoggedIn) {
dispatch(fetchUserAndCourse());
dispatch(SessionActions.fetchUserAndCourse());
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down
74 changes: 0 additions & 74 deletions src/commons/application/actions/SessionActions.ts
Copy link
Member Author

Choose a reason for hiding this comment

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

@sayomaki @chownces Just wanted to check if you're agreeable to removing the named exports to favour the default exports (and fully qualified names).

Original file line number Diff line number Diff line change
Expand Up @@ -110,46 +110,6 @@ const newActions = createActions('session', {
updateAssessmentOverviews: (overviews: AssessmentOverview[]) => overviews
});

// For compatibility with existing code (reducer)
export const {
fetchAuth,
fetchUserAndCourse,
fetchCourseConfig,
fetchAssessment,
fetchAssessmentAdmin,
fetchAssessmentOverviews,
fetchTotalXp,
fetchTotalXpAdmin,
fetchGrading,
fetchGradingOverviews,
fetchTeamFormationOverviews,
fetchStudents,
login,
logoutGoogle,
loginGitHub,
logoutGitHub,
setTokens,
setUser,
setCourseConfiguration,
setCourseRegistration,
setAssessmentConfigurations,
setConfigurableNotificationConfigs,
setNotificationConfigs,
setAdminPanelCourseRegistrations,
setGoogleUser,
setGitHubOctokitObject,
setGitHubAccessToken,
removeGitHubOctokitObjectAndAccessToken,
submitAnswer,
checkAnswerLastModifiedAt,
submitAssessment,
submitGrading,
submitGradingAndContinue,
reautogradeSubmission,
reautogradeAnswer,
updateAssessmentOverviews
} = newActions;

export const updateTotalXp = createAction(UPDATE_TOTAL_XP, (totalXp: number) => ({
payload: totalXp
}));
Expand Down Expand Up @@ -214,40 +174,6 @@ export const updateCourseResearchAgreement = createAction(
(agreedToResearch: boolean) => ({ payload: { agreedToResearch } })
);

// For compatibility with existing code (reducer)
export const {
updateGradingOverviews,
fetchTeamFormationOverview,
createTeam,
updateTeam,
deleteTeam,
bulkUploadTeam,
updateTeamFormationOverviews,
updateTeamFormationOverview,
updateStudents,
updateGrading,
unsubmitSubmission,
publishGrading,
unpublishGrading,
fetchNotifications,
acknowledgeNotifications,
updateNotifications,
updateLatestViewedCourse,
updateCourseConfig,
fetchAssessmentConfigs,
updateAssessmentConfigs,
updateNotificationConfigs,
updateNotificationPreferences,
deleteAssessmentConfig,
fetchAdminPanelCourseRegistrations,
fetchConfigurableNotificationConfigs,
fetchNotificationConfigs,
updateTimeOptions,
deleteTimeOptions,
updateUserRole,
deleteUserCourseRegistration
} = newActions2;

// For compatibility with existing code (actions helper)
export default {
...newActions,
Expand Down
Loading
Loading