Skip to content

Commit

Permalink
Merge pull request #2905 from ChildMindInstitute/bugfix/M2-295
Browse files Browse the repository at this point in the history
Bugfix/m2 295
  • Loading branch information
BamMironov authored Dec 29, 2022
2 parents 8d5c833 + 68960b5 commit c601d37
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MindLogger 0.21.77
# MindLogger 0.21.78

_Note: v0.1 is deprecated as of June 12, 2019._

Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ android {
applicationId "lab.childmindinstitute.data"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 632
versionName "0.21.77"
versionCode 633
versionName "0.21.78"
missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/ActivityList/sortActivities.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const getActual = (activityList, finishedEvents) => {

const { scheduledTime, data } = event;

const secondsPerDay = 864000;
const secondsPerDay = 86400;
const secondsPerHour = 3600;
const secondsPerMinute = 60;

Expand Down
14 changes: 2 additions & 12 deletions app/features/notifications/factories/NotificationsBuilder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import moment from "moment";
import { v4 as uuidv4 } from "uuid";

import { buildExactDateFromUTC } from '../../../utils'

import {
getActivityPrefixedId,
getActivityFlowPrefixedId,
Expand Down Expand Up @@ -660,16 +662,4 @@ export const getNotificationArray = (notificationsObject) => {
return result;
};

function buildExactDateFromUTC(date) {
const utcMoment = moment.utc(date);

const year = utcMoment.year();
const month = utcMoment.month();
const day = utcMoment.date();
const hours = utcMoment.hours();
const minutes = utcMoment.minutes();

return new Date(year, month, day, hours, minutes);
}

export default { build };
27 changes: 21 additions & 6 deletions app/models/json-ld.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getNextScheduled,
getScheduledNotifications,
} from '../services/time';
import { getIdBySplit } from '../utils'
import { getIdBySplit, buildExactDateFromUTC } from '../utils'

const ALLOW = "reprolib:terms/allow";
const ABOUT = "reprolib:terms/landingPage";
Expand Down Expand Up @@ -1112,6 +1112,14 @@ export const dateParser = (schedule) => {
return output;
};

const transformScheduleDatesFromUTC = (schedule) => {
return {
...schedule,
start: schedule.start ? buildExactDateFromUTC(schedule.start).valueOf() : undefined,
end: schedule.end ? buildExactDateFromUTC(schedule.end).valueOf() : undefined,
};
}

export const parseAppletEvents = (applet) => {
const extraInfoActivities = applet.activities.map((act) => {
const events = [];
Expand All @@ -1125,7 +1133,9 @@ export const parseAppletEvents = (applet) => {
const date = new Date();
date.setHours(0); date.setMinutes(0); date.setSeconds(0);

const futureSchedule = Parse.schedule(event.schedule).forecast(
const eventSchedule = transformScheduleDatesFromUTC(event.schedule);

const futureSchedule = Parse.schedule(eventSchedule).forecast(
Day.fromDate(date),
true,
1,
Expand All @@ -1147,16 +1157,19 @@ export const parseAppletEvents = (applet) => {

const activityFlows = applet.activityFlows.map(activityFlow => {
const events = [];

const activityFlowId = getIdBySplit(activityFlow.id);
const availability = getActivityAbility(applet.schedule, activityFlow.name, false);

for (let eventId in applet.schedule.events) {
const event = applet.schedule.events[eventId];

if (event.data.title === activityFlow.name) {
if (event.data.activity_flow_id === activityFlowId) {
const date = new Date();
date.setHours(0); date.setMinutes(0); date.setSeconds(0);

const futureSchedule = Parse.schedule(event.schedule).forecast(
const eventSchedule = transformScheduleDatesFromUTC(event.schedule);

const futureSchedule = Parse.schedule(eventSchedule).forecast(
Day.fromDate(date),
true,
1,
Expand Down Expand Up @@ -1199,7 +1212,9 @@ export const parseAppletEvents = (applet) => {
: value;

} else {
const parsedSchedule = Parse.schedule(event.schedule);
const eventSchedule = transformScheduleDatesFromUTC(event.schedule);

const parsedSchedule = Parse.schedule(eventSchedule);
const futureSchedule = parsedSchedule.forecast(
Day.fromDate(date),
true,
Expand Down
4 changes: 2 additions & 2 deletions app/state/applets/applets.thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { prepareResponseKeys, addScheduleNotificationsReminder, clearScheduleNot
import { debugScheduledNotifications } from '../../utils/debug-utils'

import { downloadAppletsMedia, downloadAppletMedia } from '../media/media.thunks';
import { activitiesSelector, allAppletsSelector } from './applets.selectors';
import { activitiesSelector, allAppletsSelector, appletsSelector } from './applets.selectors';
import {
replaceTargetAppletSchedule,
setDownloadingApplets,
Expand Down Expand Up @@ -97,7 +97,7 @@ export const setLocalNotifications = (trigger) => async (
const setLocalNotificationsInternal = async (dispatch, getState, trigger) => {
const state = getState();

const applets = allAppletsSelector(state);
const applets = appletsSelector(state);

const { finishedTimes } = state.app;

Expand Down
14 changes: 14 additions & 0 deletions app/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import moment from 'moment';

const DelayCheckResult = {
Cancel: 1,
Postpone: 2,
Expand Down Expand Up @@ -37,3 +39,15 @@ export function withDelayer(fn, { repeatIn = 1000, check }) {
}

export const getIdBySplit = (sid) => sid.split("/").pop();

export function buildExactDateFromUTC(date) {
const utcMoment = moment.utc(date);

const year = utcMoment.year();
const month = utcMoment.month();
const day = utcMoment.date();
const hours = utcMoment.hours();
const minutes = utcMoment.minutes();

return new Date(year, month, day, hours, minutes);
}
8 changes: 4 additions & 4 deletions ios/MDCApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -830,14 +830,14 @@
CODE_SIGN_ENTITLEMENTS = MDCApp/MDCApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 632;
CURRENT_PROJECT_VERSION = 633;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 8RHKE85KB6;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = MDCApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.21.77;
MARKETING_VERSION = 0.21.78;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -863,12 +863,12 @@
CODE_SIGN_ENTITLEMENTS = MDCApp/MDCApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 632;
CURRENT_PROJECT_VERSION = 633;
DEVELOPMENT_TEAM = 8RHKE85KB6;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = MDCApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.21.77;
MARKETING_VERSION = 0.21.78;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MindLogger",
"version": "0.21.77",
"version": "0.21.78",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
Expand Down

0 comments on commit c601d37

Please sign in to comment.