diff --git a/src/store/states/commonLayout/saga/getCommons.ts b/src/store/states/commonLayout/saga/getCommons.ts index 72ed1e171b..78b2956aac 100644 --- a/src/store/states/commonLayout/saga/getCommons.ts +++ b/src/store/states/commonLayout/saga/getCommons.ts @@ -1,6 +1,11 @@ import { call, put, select } from "redux-saga/effects"; import { selectUser } from "@/pages/Auth/store/selectors"; -import { CommonService, GovernanceService, ProjectService } from "@/services"; +import { + CommonService, + GovernanceService, + ProjectService, + UserActivityService, +} from "@/services"; import { Awaited } from "@/shared/interfaces"; import { User } from "@/shared/models"; import { compareCommonsByLastActivity, isError } from "@/shared/utils"; @@ -70,11 +75,20 @@ const getProjectsInfo = async ( export function* getCommons( action: ReturnType, ) { - const { payload: commonId = "" } = action; + let { payload: commonId = "" } = action; try { const user = (yield select(selectUser())) as User | null; const userId = user?.uid; + + if (!commonId && userId) { + const userActivity = (yield call( + UserActivityService.getUserActivity, + userId, + )) as Awaited>; + commonId = userActivity?.lastVisitedCommon || ""; + } + const { data, currentCommonId } = (yield call( getProjectsInfo, commonId,