diff --git a/package-lock.json b/package-lock.json index c1dca40a..211242be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lmm-oa-sws", - "version": "2.37.2", + "version": "2.38.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lmm-oa-sws", - "version": "2.37.2", + "version": "2.38.2", "dependencies": { "@emotion/react": "^11.10.6", "@emotion/styled": "^11.10.6", diff --git a/src/config/firebase.js b/src/config/firebase.js index dce2d6eb..4e775c87 100644 --- a/src/config/firebase.js +++ b/src/config/firebase.js @@ -7,15 +7,18 @@ const firebaseConfig = { projectId: import.meta.env.VITE_FIREBASE_PROJECTID, }; -const firebaseAnalyticsConfig = { - apiKey: import.meta.env.VITE_FIREBASE_ANALYTICS_APIKEY, - authDomain: import.meta.env.VITE_FIREBASE_ANALYTICS_AUTHDOMAIN, - projectId: import.meta.env.VITE_FIREBASE_ANALYTICS_PROJECTID, - appId: import.meta.env.VITE_FIREBASE_ANALYTICS_APPID, - measurementId: import.meta.env.VITE_FIREBASE_ANALYTICS_MEASUREMENTID, -}; - initializeApp(firebaseConfig); -const appAnalytics = initializeApp(firebaseAnalyticsConfig, 'appAnalytics'); -getAnalytics(appAnalytics); +const isDev = process.env.NODE_ENV === 'development'; +if (!isDev) { + const firebaseAnalyticsConfig = { + apiKey: import.meta.env.VITE_FIREBASE_ANALYTICS_APIKEY, + authDomain: import.meta.env.VITE_FIREBASE_ANALYTICS_AUTHDOMAIN, + projectId: import.meta.env.VITE_FIREBASE_ANALYTICS_PROJECTID, + appId: import.meta.env.VITE_FIREBASE_ANALYTICS_APPID, + measurementId: import.meta.env.VITE_FIREBASE_ANALYTICS_MEASUREMENTID, + }; + + const appAnalytics = initializeApp(firebaseAnalyticsConfig, 'appAnalytics'); + getAnalytics(appAnalytics); +} diff --git a/src/features/schedules/S140AssignedPerson.jsx b/src/features/schedules/S140AssignedPerson.jsx index cf13b2dc..4b198550 100644 --- a/src/features/schedules/S140AssignedPerson.jsx +++ b/src/features/schedules/S140AssignedPerson.jsx @@ -1,9 +1,10 @@ +import { Markup } from 'interweave'; import Typography from '@mui/material/Typography'; const S140AssignedPerson = ({ person }) => { return ( - {person} + ); }; diff --git a/src/features/settings/BasicSettings.jsx b/src/features/settings/BasicSettings.jsx index 58f73784..43d77f5c 100644 --- a/src/features/settings/BasicSettings.jsx +++ b/src/features/settings/BasicSettings.jsx @@ -1,18 +1,15 @@ import { useEffect, useState } from 'react'; -import { useRecoilState, useSetRecoilState } from 'recoil'; +import { useRecoilState, useRecoilValue } from 'recoil'; import { useTranslation } from 'react-i18next'; import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; import { TimePicker } from '@mui/x-date-pickers/TimePicker'; import Box from '@mui/material/Box'; -import Button from '@mui/material/Button'; import Divider from '@mui/material/Divider'; import MenuItem from '@mui/material/MenuItem'; -import SaveIcon from '@mui/icons-material/Save'; import TextField from '@mui/material/TextField'; import Typography from '@mui/material/Typography'; import { dbGetAppSettings, dbUpdateAppSettings } from '../../indexedDb/dbAppSettings'; -import { appMessageState, appSeverityState, appSnackOpenState } from '../../states/notification'; import { classCountState, congNameState, @@ -25,82 +22,52 @@ import { generateDisplayName } from '../../utils/person'; const BasicSettings = () => { const { t } = useTranslation('ui'); - const [isErrorCongName, setIsErrorCongName] = useState(false); - const [isErrorCongNumber, setIsErrorCongNumber] = useState(false); - - const [congName, setCongName] = useRecoilState(congNameState); - const [congNumber, setCongNumber] = useRecoilState(congNumberState); - const [meetingDay, setMeetingDay] = useRecoilState(meetingDayState); const [classCount, setClassCount] = useRecoilState(classCountState); + const [meetingDay, setMeetingDay] = useRecoilState(meetingDayState); const [meetingTime, setMeetingTime] = useRecoilState(meetingTimeState); - const setAppSnackOpen = useSetRecoilState(appSnackOpenState); - const setAppSeverity = useSetRecoilState(appSeverityState); - const setAppMessage = useSetRecoilState(appMessageState); + const congName = useRecoilValue(congNameState); + const congNumber = useRecoilValue(congNumberState); - const [tempCongName, setTempCongName] = useState(congName); - const [tempCongNumber, setTempCongNumber] = useState(congNumber); const [tempMeetingDay, setTempMeetingDay] = useState(meetingDay); const [tempClassCount, setTempClassCount] = useState(classCount); const [tempMeetingTime, setTempMeetingTime] = useState(meetingTime); const [coName, setCoName] = useState(''); const [coDisplayName, setCoDisplayName] = useState(''); - const handleCongNameChange = (value) => { - if (value) { - setIsErrorCongName(false); - } else { - setIsErrorCongName(true); - } - setTempCongName(value); - }; - - const handleCongNumberChange = (value) => { - if (value) { - setIsErrorCongNumber(false); - } else { - setIsErrorCongNumber(true); - } - setTempCongNumber(value); - }; - - const handleMeetingDayChange = (e) => { + const handleMeetingDayChange = async (e) => { setTempMeetingDay(e.target.value); + await dbUpdateAppSettings({ meeting_day: e.target.value }); + setMeetingDay(e.target.value); }; - const handleClassChange = (e) => { + const handleClassChange = async (e) => { setTempClassCount(e.target.value); + await dbUpdateAppSettings({ class_count: e.target.value }); + setClassCount(e.target.value); }; - const handleMeetingTimeChange = (value) => { + const handleMeetingTimeChange = async (value) => { setTempMeetingTime(value); + await dbUpdateAppSettings({ meeting_time: value }); + setMeetingTime(value); }; - const handleChangeCOName = (value) => { + const handleChangeCOName = async (value) => { setCoName(value); - setCoDisplayName(generateDisplayName(value)); - }; - const saveAppSettings = async () => { + const dispName = generateDisplayName(value); + setCoDisplayName(dispName); + const obj = {}; - obj.cong_name = tempCongName; - obj.cong_number = tempCongNumber; - obj.class_count = tempClassCount; - obj.meeting_day = tempMeetingDay; - obj.meeting_time = tempMeetingTime; - obj.co_name = coName; - obj.co_displayName = coDisplayName; + obj.co_name = value; + obj.co_displayName = dispName; await dbUpdateAppSettings(obj); + }; - setCongName(tempCongName); - setCongNumber(tempCongNumber); - setClassCount(tempClassCount); - setMeetingDay(tempMeetingDay); - setMeetingTime(tempMeetingTime); - - setAppSnackOpen(true); - setAppSeverity('success'); - setAppMessage(t('saved')); + const handleChangeCODispName = async (value) => { + setCoDisplayName(value); + await dbUpdateAppSettings({ co_displayName: value }); }; useEffect(() => { @@ -126,11 +93,8 @@ const BasicSettings = () => { size="small" autoComplete="off" required - error={isErrorCongName ? true : false} - helperText={isErrorCongName ? t('blankRequired') : null} sx={{ width: '320px' }} - value={tempCongName} - onChange={(e) => handleCongNameChange(e.target.value)} + value={congName} InputProps={{ readOnly: true, }} @@ -143,11 +107,8 @@ const BasicSettings = () => { size="small" autoComplete="off" required - error={isErrorCongNumber ? true : false} - helperText={isErrorCongName ? t('blankRequired') : null} sx={{ width: '120px' }} - value={tempCongNumber} - onChange={(e) => handleCongNumberChange(e.target.value)} + value={congNumber} InputProps={{ readOnly: true, }} @@ -224,19 +185,9 @@ const BasicSettings = () => { autoComplete="off" sx={{ width: '200px' }} value={coDisplayName} - onChange={(e) => setCoDisplayName(e.target.value)} + onChange={(e) => handleChangeCODispName(e.target.value)} /> - - ); diff --git a/src/features/settings/DataStorage.jsx b/src/features/settings/DataStorage.jsx index fdf3722a..14753e39 100644 --- a/src/features/settings/DataStorage.jsx +++ b/src/features/settings/DataStorage.jsx @@ -21,7 +21,7 @@ const DataStorage = () => { const setIsDeleteDb = useSetRecoilState(isDeleteDbOpenState); const [isAutoBackup, setIsAutoBackup] = useState(false); - const [backupInterval, setBackupInterval] = useState(1); + const [backupInterval, setBackupInterval] = useState(5); const handleAutoBackupChange = async (value) => { setIsAutoBackup(value); @@ -47,7 +47,7 @@ const DataStorage = () => { const fillDetails = async () => { const settings = await dbGetAppSettings(); setIsAutoBackup(settings.autoBackup); - setBackupInterval(settings.autoBackup_interval || 1); + setBackupInterval(settings.autoBackup_interval || 5); }; fillDetails(); @@ -72,11 +72,11 @@ const DataStorage = () => { label={t('backupIntervalLabel')} size="small" sx={{ minWidth: '130px' }} - defaultValue={1} + defaultValue={5} value={backupInterval} onChange={(e) => handleBackupIntervalChange(e.target.value)} > - {[1, 5, 15, 30].map((time) => ( + {[5, 15, 30, 45].map((time) => ( {time} min. diff --git a/src/features/settings/SourceLangSwitcher.jsx b/src/features/settings/SourcesFormsSettings.jsx similarity index 64% rename from src/features/settings/SourceLangSwitcher.jsx rename to src/features/settings/SourcesFormsSettings.jsx index fc68ec4f..b23f35fc 100644 --- a/src/features/settings/SourceLangSwitcher.jsx +++ b/src/features/settings/SourcesFormsSettings.jsx @@ -1,59 +1,54 @@ import { useState } from 'react'; -import { useRecoilState, useSetRecoilState } from 'recoil'; +import { useRecoilState, useRecoilValue } from 'recoil'; import { useTranslation } from 'react-i18next'; import Box from '@mui/material/Box'; -import Button from '@mui/material/Button'; +import Checkbox from '@mui/material/Checkbox'; import Divider from '@mui/material/Divider'; +import FormControlLabel from '@mui/material/FormControlLabel'; import LanguageIcon from '@mui/icons-material/Language'; import Link from '@mui/material/Link'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import MenuItem from '@mui/material/MenuItem'; -import SaveIcon from '@mui/icons-material/Save'; import TextField from '@mui/material/TextField'; import Typography from '@mui/material/Typography'; import { dbUpdateAppSettings } from '../../indexedDb/dbAppSettings'; -import { appMessageState, appSeverityState, appSnackOpenState } from '../../states/notification'; import { sourceLangState } from '../../states/main'; import { LANGUAGE_LIST } from '../../locales/langList'; +import { scheduleUseFullnameState } from '../../states/schedule'; -const SourceLangSwitcher = () => { +const SourcesFormsSettings = () => { const { t } = useTranslation('ui'); - const setAppSnackOpen = useSetRecoilState(appSnackOpenState); - const setAppSeverity = useSetRecoilState(appSeverityState); - const setAppMessage = useSetRecoilState(appMessageState); - const [sourceLang, setSourceLang] = useRecoilState(sourceLangState); + const [scheduleUseFullname, setScheduleUseFullname] = useRecoilState(scheduleUseFullnameState); + + const sourceLang = useRecoilValue(sourceLangState); const [tempSourceLang, setTempSourceLang] = useState(sourceLang); + const [useFullname, setUseFullname] = useState(scheduleUseFullname); const listSourceLangs = LANGUAGE_LIST.filter((lang) => lang.isSource === true); - const handleSourceLangChange = (e) => { + const handleSourceLangChange = async (e) => { if (e.target.value === 'not_set') return; setTempSourceLang(e.target.value); + await dbUpdateAppSettings({ source_lang: e.target.value }); }; - const saveAppSettings = async () => { - const obj = {}; - obj.source_lang = tempSourceLang; - await dbUpdateAppSettings(obj); - - setSourceLang(tempSourceLang); - - setAppSnackOpen(true); - setAppSeverity('success'); - setAppMessage(t('saved')); + const handleChangeFullnameSwitch = async (value) => { + setUseFullname(value); + setScheduleUseFullname(value); + await dbUpdateAppSettings({ schedule_useFullname: value }); }; return ( - {t('sourceTemplateLang')} + {t('sourcesFormsSettings')} - - {t('sourceTemplateLangDesc')} - + + {t('sourceTemplateLangDesc')} + { - + + handleChangeFullnameSwitch(e.target.checked)} />} + label={t('scheduleUseFullname')} + /> + ); }; -export default SourceLangSwitcher; +export default SourcesFormsSettings; diff --git a/src/features/settings/index.jsx b/src/features/settings/index.jsx index 5df72ccf..0dadfad9 100644 --- a/src/features/settings/index.jsx +++ b/src/features/settings/index.jsx @@ -2,7 +2,7 @@ export { default as BasicSettings } from './BasicSettings'; export { default as DataStorage } from './DataStorage'; export { default as DialogDbDeletion } from './DialogDbDeletion'; export { default as MyAccount } from './MyAccount'; -export { default as SourceLangSwitcher } from './SourceLangSwitcher'; +export { default as SourcesFormsSettings } from './SourcesFormsSettings'; export { default as User2FA } from './User2FA'; export { default as UserFullname } from './UserFullname'; export { default as UserSessionItem } from './UserSessionItem'; diff --git a/src/features/startup/CongregationCreate.jsx b/src/features/startup/CongregationCreate.jsx index 582d77a2..2725e4e6 100644 --- a/src/features/startup/CongregationCreate.jsx +++ b/src/features/startup/CongregationCreate.jsx @@ -135,7 +135,19 @@ const CongregationCreate = () => { }; useEffect(() => { - if (user) setUserTmpFullname(user.displayName || ''); + if (user) { + if (user.displayName !== null) { + setUserTmpFullname(user.displayName); + return; + } + + if (user.displayName === null && user.providerData[0]?.displayName !== null) { + setUserTmpFullname(user.providerData[0].displayName); + return; + } + + setUserTmpFullname(''); + } }, [user]); useEffect(() => { diff --git a/src/indexedDb/dbSchedule.js b/src/indexedDb/dbSchedule.js index 50728346..cea66ace 100644 --- a/src/indexedDb/dbSchedule.js +++ b/src/indexedDb/dbSchedule.js @@ -30,14 +30,17 @@ export const dbGetBaseScheduleDate = async (weekValue) => { } for await (const item of assList) { + const fldName = `${item.assignment}_name`; const fldDispName = `${item.assignment}_dispName`; if (item.person) { const student = await dbGetStudentByUid(item.person); schedule[item.assignment] = item.person; + schedule[fldName] = student?.person_name || ''; schedule[fldDispName] = student?.person_displayName || ''; } else { schedule[item.assignment] = ''; + schedule[fldName] = ''; schedule[fldDispName] = ''; } } diff --git a/src/indexedDb/mainDb.js b/src/indexedDb/mainDb.js index afbe1b55..b5271fcf 100644 --- a/src/indexedDb/mainDb.js +++ b/src/indexedDb/mainDb.js @@ -257,6 +257,11 @@ appDb.version(63).stores({ '++id, username, local_uid, source_lang, cong_number, cong_name, class_count, meeting_day, meeting_time, isScheduleConverted, isCongVerified, isAssignmentsConverted, isCongUpdated2, pocket_members, user_avatar, account_version, co_name, co_displayName, personAssignmentsConverted, autoBackup, autoBackup_interval', }); +appDb.version(64).stores({ + app_settings: + '++id, username, local_uid, source_lang, cong_number, cong_name, class_count, meeting_day, meeting_time, isScheduleConverted, isCongVerified, isAssignmentsConverted, isCongUpdated2, pocket_members, user_avatar, account_version, co_name, co_displayName, personAssignmentsConverted, autoBackup, autoBackup_interval, schedule_useFullname', +}); + appDb.on('populate', function () { appDb.app_settings.add({ id: 1, @@ -272,6 +277,7 @@ appDb.on('populate', function () { pocket_members: [], account_version: 'v2', personAssignmentsConverted: true, + schedule_useFullname: false, }); }); diff --git a/src/locales/en/ui.json b/src/locales/en/ui.json index f7df9ec0..6173da6b 100644 --- a/src/locales/en/ui.json +++ b/src/locales/en/ui.json @@ -380,7 +380,7 @@ "sessionRevoke": "Revoke", "lastSeen": "Last seen: {{ last_seen }}", "currentSession": "Current session", - "sourceTemplateLang": "SOURCE MATERIALS & FORM LANGUAGE", + "sourcesFormsSettings": "SOURCE MATERIALS & FORMS", "sourceTemplateLangDesc": "Select the language you want to use for source materials, S-89 and S-140 forms", "heading": "Manage Access to CPE", "vipUsersHeading": "Baptized Brothers", @@ -475,5 +475,6 @@ "weekDeletedSuccess": "Week removed from source materials", "autoBackup": "CPE Automatic Backup", "enableLabel": "Enable", - "backupIntervalLabel": "Interval" + "backupIntervalLabel": "Interval", + "scheduleUseFullname": "Use Fullname in S-140" } diff --git a/src/pages/CongregationSettings.jsx b/src/pages/CongregationSettings.jsx index b6a1820f..f7ffa4f2 100644 --- a/src/pages/CongregationSettings.jsx +++ b/src/pages/CongregationSettings.jsx @@ -1,5 +1,5 @@ import Box from '@mui/material/Box'; -import { BasicSettings, DataStorage, SourceLangSwitcher } from '../features/settings'; +import { BasicSettings, DataStorage, SourcesFormsSettings } from '../features/settings'; const sharedStyles = { settingItem: { @@ -12,7 +12,7 @@ const CongregationSettings = () => { return ( - + diff --git a/src/pages/S140.jsx b/src/pages/S140.jsx index 248a5930..ab1ac06d 100644 --- a/src/pages/S140.jsx +++ b/src/pages/S140.jsx @@ -8,7 +8,7 @@ import Button from '@mui/material/Button'; import SaveAltIcon from '@mui/icons-material/SaveAlt'; import Typography from '@mui/material/Typography'; import { monthNamesState, rootModalOpenState, sourceLangState } from '../states/main'; -import { currentScheduleState } from '../states/schedule'; +import { currentScheduleState, scheduleUseFullnameState } from '../states/schedule'; import { classCountState, congNameState, congNumberState } from '../states/congregation'; import { dbGetScheduleForPrint } from '../indexedDb/dbAssignment'; import { @@ -33,6 +33,7 @@ const S140 = () => { const congNumber = useRecoilValue(congNumberState); const monthNames = useRecoilValue(monthNamesState); const sourceLang = useRecoilValue(sourceLangState); + const scheduleUseFullname = useRecoilValue(scheduleUseFullnameState); const [data, setData] = useState([]); @@ -73,7 +74,7 @@ const S140 = () => { return ''; }; - const getAssignedAYFPerson = (weekItem, fldType, fldStu, fldAss, stuClass) => { + const getAssignedAYFPerson = (weekItem, fldType, fldStu, fldAss, stuClass, scheduleUseFullname) => { if ( weekItem.sourceData[fldType] === 101 || weekItem.sourceData[fldType] === 102 || @@ -89,7 +90,8 @@ const S140 = () => { weekItem.scheduleData[fldAss] !== '' && weekItem.scheduleData[fldAss] !== 'undefined' ) { - src += `/${weekItem.scheduleData[fldAss]}`; + src += ' / '; + src += weekItem.scheduleData[fldAss]; } return src; @@ -102,7 +104,11 @@ const S140 = () => { weekItem.sourceData[fldType] === 117 ) { return stuClass === 'A' - ? weekItem.scheduleData.chairmanMM_A_dispName + ? scheduleUseFullname + ? weekItem.scheduleData.chairmanMM_A_name + : weekItem.scheduleData.chairmanMM_A_dispName + : scheduleUseFullname + ? weekItem.scheduleData.chairmanMM_B_name : weekItem.scheduleData.chairmanMM_B_dispName; } @@ -146,10 +152,13 @@ const S140 = () => { return `${src}:`; }; - const getAssignedCBS = (weekItem) => { - let src = weekItem.scheduleData.cbs_conductor_dispName; + const getAssignedCBS = (weekItem, scheduleUseFullname) => { + let src = scheduleUseFullname + ? weekItem.scheduleData.cbs_conductor_name + : weekItem.scheduleData.cbs_conductor_dispName; if (weekItem.scheduleData.cbs_reader_dispName && weekItem.scheduleData.cbs_reader_dispName !== '') { - src += `/${weekItem.scheduleData.cbs_reader_dispName}`; + src += ' / '; + src += scheduleUseFullname ? weekItem.scheduleData.cbs_reader_name : weekItem.scheduleData.cbs_reader_dispName; } return src; @@ -280,7 +289,13 @@ const S140 = () => { label={`${t('chairmanMidweekMeeting', { lng: sourceLang, ns: 'source' })}:`} width="180px" /> - + )} @@ -307,7 +322,13 @@ const S140 = () => { width="180px" /> )} @@ -327,7 +348,13 @@ const S140 = () => { label={`${t('prayerMidweekMeeting', { lng: sourceLang, ns: 'source' })}:`} width="180px" /> - + {/* 4th row for opening comments */} @@ -363,7 +390,13 @@ const S140 = () => { partDuration="10 min." /> - + {/* TGW Gems */} @@ -375,7 +408,13 @@ const S140 = () => { partDuration="10 min." /> - + {/* Bible Reading */} @@ -388,9 +427,21 @@ const S140 = () => { partMiniLabel={`${t('student', { lng: sourceLang })}:`} /> + - {/* AYF Heading */} @@ -407,10 +458,18 @@ const S140 = () => { const fldType = 'ass' + index + '_type'; const fldTime = 'ass' + index + '_time'; const fldSrc = 'ass' + index + '_src'; - const fldStuA = 'ass' + index + '_stu_A_dispName'; - const fldAssA = 'ass' + index + '_ass_A_dispName'; - const fldStuB = 'ass' + index + '_stu_B_dispName'; - const fldAssB = 'ass' + index + '_ass_B_dispName'; + const fldStuA = scheduleUseFullname + ? 'ass' + index + '_stu_A_name' + : 'ass' + index + '_stu_A_dispName'; + const fldAssA = scheduleUseFullname + ? 'ass' + index + '_ass_A_name' + : 'ass' + index + '_ass_A_dispName'; + const fldStuB = scheduleUseFullname + ? 'ass' + index + '_stu_B_name' + : 'ass' + index + '_stu_B_dispName'; + const fldAssB = scheduleUseFullname + ? 'ass' + index + '_ass_B_name' + : 'ass' + index + '_ass_B_dispName'; const fldAyfPart = 'ayf' + index; return ( @@ -427,11 +486,25 @@ const S140 = () => { )} @@ -459,7 +532,9 @@ const S140 = () => { const fldTimeOverride = 'lcPart' + index + '_time_override'; const fldSrc = 'lcPart' + index + '_src'; const fldSrcOverride = 'lcPart' + index + '_src_override'; - const fldPers = 'lc_part' + index + '_dispName'; + const fldPers = scheduleUseFullname + ? 'lc_part' + index + '_name' + : 'lc_part' + index + '_dispName'; const fldLcPart = 'lc' + index; return ( @@ -492,7 +567,13 @@ const S140 = () => { partDuration="3 min." /> - + {/* Talk by CO */} @@ -504,7 +585,13 @@ const S140 = () => { partDuration="30 min." /> - + )} @@ -513,7 +600,7 @@ const S140 = () => { {weekItem.scheduleData.week_type === 1 && ( <> {/* CBS */} - + { partDuration={`${getCBSTime(weekItem)} min.`} /> - + {/* Concluding Comments */} @@ -533,7 +620,13 @@ const S140 = () => { partDuration="3 min." /> - + )} @@ -547,7 +640,13 @@ const S140 = () => { label={`${t('prayerMidweekMeeting', { lng: sourceLang, ns: 'source' })}:`} width="180px" /> - + )} diff --git a/src/states/schedule.js b/src/states/schedule.js index de5cc854..545a3eeb 100644 --- a/src/states/schedule.js +++ b/src/states/schedule.js @@ -89,3 +89,8 @@ export const reloadWeekSummaryState = atom({ key: 'reloadWeekSummary', default: false, }); + +export const scheduleUseFullnameState = atom({ + key: 'scheduleUseFullname', + default: false, +}); diff --git a/src/utils/app.js b/src/utils/app.js index 636877f3..6ce3e15b 100644 --- a/src/utils/app.js +++ b/src/utils/app.js @@ -24,6 +24,7 @@ import { import { assTypeListState, weekTypeListState, yearsListState } from '../states/sourceMaterial'; import { allStudentsState, filteredStudentsState, studentsAssignmentHistoryState } from '../states/persons'; import backupWorkerInstance from '../workers/backupWorker'; +import { scheduleUseFullnameState } from '../states/schedule'; export const loadApp = async () => { const I18n = getI18n(); @@ -41,6 +42,7 @@ export const loadApp = async () => { user_avatar, autoBackup, autoBackup_interval, + schedule_useFullname, } = await dbGetAppSettings(); backupWorkerInstance.setBackupInterval(autoBackup_interval); @@ -70,6 +72,7 @@ export const loadApp = async () => { await promiseSetRecoil(meetingTimeState, meeting_time || new Date(Date.now())); await promiseSetRecoil(appLangState, app_lang); await promiseSetRecoil(sourceLangState, source_lang || app_lang); + await promiseSetRecoil(scheduleUseFullnameState, schedule_useFullname || false); if (source_lang === undefined) await dbUpdateAppSettings({ source_lang: app_lang }); diff --git a/src/utils/updater.js b/src/utils/updater.js index 8bca5a2e..6721059b 100644 --- a/src/utils/updater.js +++ b/src/utils/updater.js @@ -657,9 +657,24 @@ const updatePersonAssignments = async () => { }; const checkAutoBackup = async () => { - const appSettings = await dbGetAppSettings(); + let appSettings = await dbGetAppSettings(); if (appSettings.autoBackup === undefined) { - const obj = { autoBackup: true, autoBackup_inteval: 1 }; + const obj = { autoBackup_interval: 5 }; await dbUpdateAppSettings(obj); } + + if (appSettings.autoBackup_interval === undefined) { + const obj = { autoBackup_interval: 5 }; + await dbUpdateAppSettings(obj); + } + + if (appSettings.autoBackup_interval === 1) { + await dbUpdateAppSettings({ autoBackup_interval: 5 }); + } + + appSettings = await dbGetAppSettings(); + if (appSettings.autoBackup_inteval) { + delete appSettings.autoBackup_inteval; + await dbUpdateAppSettings({ ...appSettings }, true); + } };