Skip to content

Commit

Permalink
feat(deps): bump jw-epub-parser from 2.0.0 to 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Sep 27, 2023
1 parent 35bd75a commit 17ea0bb
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 81 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"html2pdf.js": "^0.10.1",
"i18next": "^23.5.1",
"interweave": "^13.1.0",
"jw-epub-parser": "^2.0.0",
"jw-epub-parser": "^3.0.0",
"mui-one-time-password-input": "^2.0.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Person.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PersonClass.prototype.assistantHistory = function () {

for (const schedule of Schedules.list) {
const weekData = Sources.get(schedule.weekOf).local();
const [varMonth, varDay, varYear] = schedule.weekOf.split('/');
const [varYear, varMonth, varDay] = schedule.weekOf.split('/');
const lDate = new Date(varYear, varMonth - 1, varDay);
const dateFormatted = dateFormat(lDate, Setting.shortDateFormat());
const cnAss = [{ iAss: 1 }, { iAss: 2 }, { iAss: 3 }];
Expand Down
5 changes: 2 additions & 3 deletions src/classes/Persons.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,8 @@ PersonsClass.prototype.getByAssignment = function (payload) {
if (a[fldFilter] === '') return -1;
if (b[fldFilter] === '') return 1;
if (a[fldFilter] === b[fldFilter]) return 0;
const dateA = a[fldFilter].split('/')[2] + '/' + a[fldFilter].split('/')[0] + '/' + a[fldFilter].split('/')[1];
const dateB = b[fldFilter].split('/')[2] + '/' + b[fldFilter].split('/')[0] + '/' + b[fldFilter].split('/')[1];
return dateA > dateB ? 1 : -1;

return a[fldFilter] > b[fldFilter] ? 1 : -1;
});

return persons;
Expand Down
12 changes: 4 additions & 8 deletions src/classes/Schedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class SchedulesClass {

SchedulesClass.prototype.sort = function (arrayName) {
this[arrayName].sort((a, b) => {
const dateA = a.weekOf.split('/')[2] + '/' + a.weekOf.split('/')[0] + '/' + a.weekOf.split('/')[1];
const dateB = b.weekOf.split('/')[2] + '/' + b.weekOf.split('/')[0] + '/' + b.weekOf.split('/')[1];
return dateA < dateB ? 1 : -1;
return a.weekOf < b.weekOf ? 1 : -1;
});
};

Expand Down Expand Up @@ -162,7 +160,7 @@ SchedulesClass.prototype.S89ItemData = function (week, assName, classLabel) {

let midDay = parseInt(Setting.midweek_meeting_day, 10);

const [varMonth, varDay, varYear] = week.split('/');
const [varYear, varMonth, varDay] = week.split('/');
midDay = parseInt(varDay, 10) + midDay - 1;
const lDate = new Date(varYear, varMonth - 1, midDay);
const dateFormatted = dateFormat(lDate, getI18n().getDataByLanguage(sourceLang).ui['shortDateFormat']);
Expand Down Expand Up @@ -588,9 +586,7 @@ SchedulesClass.prototype.updateTalkHistory = function ({ talk_number, weekOf, de
currentTalk.history.push(obj);

currentTalk.history.sort((a, b) => {
const dateA = a.weekOf.split('/')[2] + '/' + a.weekOf.split('/')[0] + '/' + a.weekOf.split('/')[1];
const dateB = b.weekOf.split('/')[2] + '/' + b.weekOf.split('/')[0] + '/' + b.weekOf.split('/')[1];
return dateA < dateB ? 1 : -1;
return a.weekOf < b.weekOf ? 1 : -1;
});

currentTalk.last_delivered = weekOf;
Expand All @@ -609,7 +605,7 @@ SchedulesClass.prototype.WeekendMeetingData = function (startWeek, endWeek) {
const WMDay = Setting.weekend_meeting_day - 1;
const tmpDate = new Date(schedule.weekOf);
const tmpWMDate = tmpDate.setDate(tmpDate.getDate() + WMDay);
const WMDate = dateFormat(tmpWMDate, 'mm/dd/yyyy');
const WMDate = dateFormat(tmpWMDate, 'yyyy/mm/dd');
const WMDateFormatted = dateFormat(tmpWMDate, Setting.shortDateFormat());

schedule.weekend_meeting_date = WMDate;
Expand Down
30 changes: 14 additions & 16 deletions src/classes/Sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class SourcesClass {

SourcesClass.prototype.sort = function () {
this.list.sort((a, b) => {
const dateA = a.weekOf.split('/')[2] + '/' + a.weekOf.split('/')[0] + '/' + a.weekOf.split('/')[1];
const dateB = b.weekOf.split('/')[2] + '/' + b.weekOf.split('/')[0] + '/' + b.weekOf.split('/')[1];
return dateA < dateB ? 1 : -1;
return a.weekOf < b.weekOf ? 1 : -1;
});
};

Expand Down Expand Up @@ -60,10 +58,10 @@ SourcesClass.prototype.scheduleListByYear = function (varYear, userSort = 'desc'

for (const source of appData) {
const weekDate = source.weekOf;
const year = weekDate.split('/')[2];
const year = weekDate.split('/')[0];

if (year === varYear) {
const month = weekDate.split('/')[0];
const month = weekDate.split('/')[1];

const tempMain = month + '/' + year;
const scheduleIndex = allSchedules.findIndex((schedule) => schedule.value === tempMain);
Expand All @@ -86,17 +84,17 @@ SourcesClass.prototype.addWeekManually = async function () {
weekDate = new Date();
} else {
const lastWeek = this.list[0].weekOf;
const day = lastWeek.split('/')[1];
const month = lastWeek.split('/')[0];
const year = lastWeek.split('/')[2];
const day = lastWeek.split('/')[2];
const month = lastWeek.split('/')[1];
const year = lastWeek.split('/')[0];
weekDate = new Date(year, month - 1, day);
weekDate.setDate(weekDate.getDate() + 7);
}

const day = weekDate.getDay();
const diff = weekDate.getDate() - day + (day === 0 ? -6 : 1);
const monDay = new Date(weekDate.setDate(diff));
const fMonday = dateFormat(monDay, 'mm/dd/yyyy');
const fMonday = dateFormat(monDay, 'yyyy/mm/dd');

if (!this.get(fMonday)) {
await appDb.sources.put({ weekOf: fMonday }, fMonday);
Expand All @@ -123,8 +121,8 @@ SourcesClass.prototype.weekListBySchedule = function (scheduleIndex) {

for (const source of this.list) {
const weekDate = source.weekOf;
const month = weekDate.split('/')[0];
const year = weekDate.split('/')[2];
const month = weekDate.split('/')[1];
const year = weekDate.split('/')[0];
const tempMain = month + '/' + year;
if (tempMain === scheduleIndex) {
allWeeks.push(weekDate);
Expand All @@ -139,9 +137,9 @@ SourcesClass.prototype.weekListByScheduleLocal = function (scheduleIndex) {

const newData = [];
data.forEach((week) => {
const day = week.split('/')[1];
const month = week.split('/')[0];
const year = week.split('/')[2];
const day = week.split('/')[2];
const month = week.split('/')[1];
const year = week.split('/')[0];
const newDate = new Date(year, +month - 1, day);
const dateFormatted = dateFormat(newDate, Setting.shortDateFormat());
newData.push({ value: week, label: dateFormatted });
Expand Down Expand Up @@ -269,7 +267,7 @@ SourcesClass.prototype.yearsList = function () {

for (const source of this.list) {
const weekDate = source.weekOf;
const varYear = weekDate.split('/')[2];
const varYear = weekDate.split('/')[0];

const yearIndex = allYear.findIndex((year) => year.label === varYear);

Expand Down Expand Up @@ -422,7 +420,7 @@ SourcesClass.prototype.hasCurrentWeek = function () {
const day = today.getDay();
const diff = today.getDate() - day + (day === 0 ? -6 : 1);
const monDay = new Date(today.setDate(diff));
const fMonday = dateFormat(monDay, 'mm/dd/yyyy');
const fMonday = dateFormat(monDay, 'yyyy/mm/dd');

if (weeksIgnore.includes(fMonday)) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/features/myAssignments/MyAssignmentsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const MyAssignmentsList = () => {

const tempData2 = tempAssignments.map((assignment) => {
const split = assignment.weekOf.split('/');
const monthIndex = +split[0] - 1;
const monthValue = `${monthNames[monthIndex]} ${split[2]}`;
const monthIndex = +split[1] - 1;
const monthValue = `${monthNames[monthIndex]} ${split[0]}`;
return { ...assignment, month_value: monthValue };
});

Expand Down
2 changes: 1 addition & 1 deletion src/features/myAssignments/MyAssignmentsMonthItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const MyAssignmentsMonthItem = ({ assignment }) => {
const { t } = useTranslation('ui');
const { weekOf, assignmentContent, assignmentName, assignmentSource, assignmentTime } = assignment;

const dateValue = weekOf.split('/')[1];
const dateValue = weekOf.split('/')[2];
const minLabel = t('minuteShortLabel');

const getSource = () => {
Expand Down
8 changes: 3 additions & 5 deletions src/features/schedules/WeekendMeetingContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ const WeekendMeetingContainer = () => {
.filter((record) => {
const startDate = new Date(2023, 5, 6);
const tmp = record.weekOf.split('/');
const recordDate = new Date(tmp[2], +tmp[0] - 1, tmp[1]);
const recordDate = new Date(tmp[0], +tmp[1] - 1, tmp[2]);

return recordDate >= startDate;
})
.sort((a, b) => {
const dateA = a.weekOf.split('/')[2] + '/' + a.weekOf.split('/')[0] + '/' + a.weekOf.split('/')[1];
const dateB = b.weekOf.split('/')[2] + '/' + b.weekOf.split('/')[0] + '/' + b.weekOf.split('/')[1];
return dateA > dateB ? 1 : -1;
return a.weekOf > b.weekOf ? 1 : -1;
}),
[]
);
Expand All @@ -58,7 +56,7 @@ const WeekendMeetingContainer = () => {

useEffect(() => {
const currentWeek = getCurrentWeekDate();
const currentWeekFormatted = dateFormat(currentWeek, 'mm/dd/yyyy');
const currentWeekFormatted = dateFormat(currentWeek, 'yyyy/mm/dd');
const findIndex = schedules.findIndex((record) => record.weekOf === currentWeekFormatted);
const weekPage = (findIndex - (findIndex % 10)) / 10;
setPage(weekPage);
Expand Down
10 changes: 4 additions & 6 deletions src/features/schedules/WeekendMeetingWeekSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ const WeekendMeetingWeekSelect = ({ actionType, open, setOpen }) => {
.filter((record) => {
const startDate = new Date(2023, 5, 6);
const tmp = record.weekOf.split('/');
const recordDate = new Date(tmp[2], +tmp[0] - 1, tmp[1]);
const recordDate = new Date(tmp[0], +tmp[1] - 1, tmp[2]);

return recordDate >= startDate;
})
.sort((a, b) => {
const dateA = a.weekOf.split('/')[2] + '/' + a.weekOf.split('/')[0] + '/' + a.weekOf.split('/')[1];
const dateB = b.weekOf.split('/')[2] + '/' + b.weekOf.split('/')[0] + '/' + b.weekOf.split('/')[1];
return dateA > dateB ? 1 : -1;
return a.weekOf > b.weekOf ? 1 : -1;
}),
[]
);
Expand Down Expand Up @@ -107,9 +105,9 @@ const WeekendMeetingWeekSelect = ({ actionType, open, setOpen }) => {
setEndWeekOptions(
schedules.filter((record) => {
const tmpStart = startWeek.split('/');
const startDate = new Date(tmpStart[2], +tmpStart[0] - 1, tmpStart[1]);
const startDate = new Date(tmpStart[0], +tmpStart[1] - 1, tmpStart[2]);
const tmpEnd = record.weekOf.split('/');
const recordDate = new Date(tmpEnd[2], +tmpEnd[0] - 1, tmpEnd[1]);
const recordDate = new Date(tmpEnd[0], +tmpEnd[1] - 1, tmpEnd[2]);

return recordDate >= startDate;
})
Expand Down
31 changes: 31 additions & 0 deletions src/indexedDb/mainDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,37 @@ appDb.version(64).stores({
visiting_speakers:
'&cong_number, cong_id, cong_name, cong_speakers, is_local, request_status, notif_dismissed, changes',
});
appDb
.version(67)
.stores({
sources:
'&weekOf, mwb_week_date_locale, mwb_weekly_bible_reading, mwb_song_first, mwb_tgw_talk, mwb_tgw_bread, mwb_ayf_count, mwb_ayf_part1, mwb_ayf_part1_time, mwb_ayf_part1_type, mwb_ayf_part2, mwb_ayf_part2_time, mwb_ayf_part2_type, mwb_ayf_part3, mwb_ayf_part3_time, mwb_ayf_part3_type, mwb_ayf_part4, mwb_ayf_part4_time, mwb_ayf_part4_type, mwb_song_middle, mwb_lc_count, mwb_lc_count_override, mwb_lc_part1, mwb_lc_part1_override, mwb_lc_part1_time, mwb_lc_part1_time_override, mwb_lc_part1_content, mwb_lc_part1_content_override, mwb_lc_part2, mwb_lc_part2_override, mwb_lc_part2_time, mwb_lc_part2_time_override, mwb_lc_part2_content, mwb_lc_part2_content_override, mwb_lc_cbs, mwb_lc_cbs_time_override, mwb_song_conclude, mwb_song_conclude_override, mwb_co_talk_title, w_study_date_locale, w_study_title, w_study_opening_song, w_study_concluding_song, w_co_talk_title, keepOverride',
sched:
'&weekOf, bRead_stu_A, bRead_stu_A_name, bRead_stu_A_dispName, bRead_stu_B, bRead_stu_B_name, bRead_stu_B_dispName, ass1_stu_A, ass1_stu_A_name, ass1_stu_A_dispName, ass1_ass_A, ass1_ass_A_name, ass1_ass_A_dispName, ass1_stu_B, ass1_stu_B_name, ass1_stu_B_dispName, ass1_ass_B, ass1_ass_B_name, ass1_ass_B_dispName, ass2_stu_A, ass2_stu_A_name, ass2_stu_A_dispName, ass2_ass_A, ass2_ass_A_name, ass2_ass_A_dispName, ass2_stu_B, ass2_stu_B_name, ass2_stu_B_dispName, ass2_ass_B, ass2_ass_B_name, ass2_ass_B_dispName, ass3_stu_A, ass3_stu_A_name, ass3_stu_A_dispName, ass3_ass_A, ass3_ass_A_name, ass3_ass_A_dispName, ass3_stu_B, ass3_stu_B_name, ass3_stu_B_dispName, ass3_ass_B, ass3_ass_B_name, ass3_ass_B_dispName, ass4_stu_A, ass4_stu_A_name, ass4_stu_A_dispName, ass4_ass_A, ass4_ass_A_name, ass4_ass_A_dispName, ass4_stu_B, ass4_stu_B_name, ass4_stu_B_dispName, ass4_ass_B, ass4_ass_B_name, ass4_ass_B_dispName, week_type, noMMeeting, isReleased, chairmanMM_A, chairmanMM_A_name, chairmanMM_A_dispName, chairmanMM_B, chairmanMM_B_name, chairmanMM_B_dispName, opening_prayerMM, opening_prayerMM_name, opening_prayerMM_dispName, tgw_talk, tgw_talk_name, tgw_talk_dispName, tgw_gems, tgw_gems_name, tgw_gems_dispName, lc_part1, lc_part1_name, lc_part1_dispName, lc_part2, lc_part2_name, lc_part2_dispName, cbs_conductor, cbs_conductor_name, cbs_conductor_dispName, cbs_reader, cbs_reader_name, cbs_reader_dispName, closing_prayerMM, closing_prayerMM_name, closing_prayerMM_dispName, chairman_WM, chairman_WM_name, chairman_WM_dispName, opening_prayerWM, opening_prayerWM_name, opening_prayerWM_dispName, speaker_1, speaker_1_name, speaker_1_dispName, speaker_2, speaker_2_name, speaker_2_dispName, is_visiting_speaker, public_talk, event_name, wtstudy_reader, wtstudy_reader_name, wtstudy_reader_dispName, noWMeeting, changes',
})
.upgrade(async (trans) => {
const sources = await trans.sources.toArray();
for await (const source of sources) {
const oldWeekOf = source.weekOf;
const str = oldWeekOf.split('/');
const newWeekOf = `${str[0]}/${str[1]}/${str[2]}`;

const data = { ...source, weekOf: newWeekOf };

await trans.sources.put(data, oldWeekOf);
}

const schedules = await trans.sched.toArray();
for await (const schedule of schedules) {
const oldWeekOf = schedule.weekOf;
const str = oldWeekOf.split('/');
const newWeekOf = `${str[0]}/${str[1]}/${str[2]}`;

const data = { ...schedule, weekOf: newWeekOf };

await trans.sched.put(data, oldWeekOf);
}
});

appDb.on('populate', function () {
appDb.app_settings.add({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ScheduleWeekDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ScheduleWeekDetails = () => {
currentDate.setDate(currentDate.getDate() - 7);
}

const dateFormatted = dateFormat(currentDate, 'mm/dd/yyyy');
const dateFormatted = dateFormat(currentDate, 'yyyy/mm/dd');
if (Sources.get(dateFormatted)) {
const newUrl = `/schedules/${schedule}/${dateFormatted.replaceAll('/', '-')}`;
navigate(newUrl);
Expand Down
10 changes: 5 additions & 5 deletions src/pages/WeeklyAssignments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,32 @@ const WeeklyAssignments = () => {

let result = new Date(currentWeek);
result.setDate(result.getDate() - 7);
let previousWeek = dateFormat(result, 'mm/dd/yyyy');
let previousWeek = dateFormat(result, 'yyyy/mm/dd');

let hasPrevious = Sources.get(previousWeek);

if (!hasPrevious) {
result.setDate(result.getDate() - 7);
previousWeek = dateFormat(result, 'mm/dd/yyyy');
previousWeek = dateFormat(result, 'yyyy/mm/dd');
hasPrevious = Sources.get(previousWeek);
}
setDisablePrevious(!hasPrevious);
setPreviousWeek(result);

result = new Date(currentWeek);
result.setDate(result.getDate() + 7);
let nextWeek = dateFormat(result, 'mm/dd/yyyy');
let nextWeek = dateFormat(result, 'yyyy/mm/dd');

let hasNext = Sources.get(nextWeek);
if (!hasNext) {
result.setDate(result.getDate() + 7);
nextWeek = dateFormat(result, 'mm/dd/yyyy');
nextWeek = dateFormat(result, 'yyyy/mm/dd');
hasNext = Sources.get(nextWeek);
}
setDisableNext(!hasNext);
setNextWeek(result);

const weekValue = dateFormat(currentWeek, 'mm/dd/yyyy');
const weekValue = dateFormat(currentWeek, 'yyyy/mm/dd');
const weekValueFormatted = dateFormat(weekValue, shortDateFormat);
setFCurrentWeek(weekValueFormatted);

Expand Down
4 changes: 2 additions & 2 deletions src/utils/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ export const getCurrentExistingWeekDate = async () => {
const diff = today.getDate() - day + (day === 0 ? -6 : 1);
let monDay = new Date(today.setDate(diff));

let currentWeek = format(monDay, 'MM/dd/yyyy');
let currentWeek = format(monDay, 'yyyy/mm/dd');
let isExist = false;

if (schedules.length > 0) {
do {
const fDate = format(monDay, 'MM/dd/yyyy');
const fDate = format(monDay, 'yyyy/mm/dd');
const schedule = schedules.find((data) => data.weekOf === fDate);
if (schedule) {
currentWeek = fDate;
Expand Down
Loading

0 comments on commit 17ea0bb

Please sign in to comment.