Skip to content

Commit

Permalink
#1193 - added custom dashboard action call after reset (part of previ…
Browse files Browse the repository at this point in the history
…ous commit)
  • Loading branch information
petmongrels committed Dec 7, 2023
1 parent 909982e commit ffac613
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 10 additions & 6 deletions packages/openchs-android/src/service/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import TaskUnAssignmentService from "./task/TaskUnAssignmentService";
import UserSubjectAssignmentService from "./UserSubjectAssignmentService";
import moment from "moment";
import AllSyncableEntityMetaData from "../model/AllSyncableEntityMetaData";
import ProgramConfigService from './ProgramConfigService';
import {IndividualSearchActionNames as IndividualSearchActions} from '../action/individual/IndividualSearchActions';
import {LandingViewActionsNames as LandingViewActions} from '../action/LandingViewActions';
import {LandingViewActionsNames as Actions, LandingViewActionsNames as LandingViewActions} from '../action/LandingViewActions';
import {MyDashboardActionNames} from '../action/mydashboard/MyDashboardActions';
import {CustomDashboardActionNames} from '../action/customDashboard/CustomDashboardActions';
import LocalCacheService from "./LocalCacheService";

@Service("syncService")
class SyncService extends BaseService {
Expand Down Expand Up @@ -373,12 +374,15 @@ class SyncService extends BaseService {
this.dispatchAction('RESET');
this.context.getService(PrivilegeService).deleteRevokedEntities(); //Invoking this in MenuView.deleteData as well

//To load subjectType after sync
this.dispatchAction(IndividualSearchActions.ON_LOAD);
this.dispatchAction(MyDashboardActionNames.ON_LOAD); //Invoking this after full sync reset as well

//To re-render LandingView after sync
this.dispatchAction(MyDashboardActionNames.ON_LOAD);
this.dispatchAction(LandingViewActions.ON_LOAD, {syncRequired});
LocalCacheService.getPreviouslySelectedSubjectTypeUuid().then(cachedSubjectTypeUUID => {
this.dispatchAction(Actions.ON_LOAD, {cachedSubjectTypeUUID});
});
this.dispatchAction(CustomDashboardActionNames.ON_LOAD, {onlyPrimary: false});
this.dispatchAction(CustomDashboardActionNames.REMOVE_OLDER_COUNTS);
setTimeout(() => this.dispatchAction(CustomDashboardActionNames.REFRESH_COUNT), 500);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class ReportCardService extends BaseService {
}

getCountForApprovalCardsType(type, reportFilters) {
const {result} = this.getResultForApprovalCardsType(type, reportFilters);
const approvalStatus_status = getApprovalStatusForType(type);
const {result} = this.getService(EntityApprovalStatusService).getAllEntitiesForReports(approvalStatus_status, reportFilters)
return {
primaryValue: _.map(result, ({data}) => data.length).reduce((total, l) => total + l, 0),
secondaryValue: null,
Expand All @@ -41,7 +42,7 @@ class ReportCardService extends BaseService {

getResultForApprovalCardsType(type, reportFilters) {
const approvalStatus_status = getApprovalStatusForType(type);
return this.getService(EntityApprovalStatusService).getAllEntitiesForReports(approvalStatus_status, reportFilters);
return this.getService(EntityApprovalStatusService).getAllSubjects(approvalStatus_status, reportFilters);
}

getCountForCommentCardType() {
Expand Down Expand Up @@ -135,7 +136,7 @@ class ReportCardService extends BaseService {
return {status: null, result};
}
case standardReportCardType.isApprovalType() :
return this.getResultForApprovalCardsType(standardReportCardType.name, reportFilters);
return {status: null, result: this.getResultForApprovalCardsType(standardReportCardType.name, reportFilters)};
case standardReportCardType.isDefaultType() :
return this.getResultForDefaultCardsType(standardReportCardType.name, reportFilters);
case standardReportCardType.isCommentType() : {
Expand Down

0 comments on commit ffac613

Please sign in to comment.