Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): add hotfixes #3173

Merged
merged 16 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .firebaserc

This file was deleted.

15 changes: 1 addition & 14 deletions src/RootWrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,7 @@ import WaitingLoader from '@components/waiting_loader';

const Migration = lazy(() => import('./migration'));

const getFont = () => {
const cookiesConsent = Boolean(localStorage.getItem('userConsent'));

if (cookiesConsent) {
return localStorage.getItem('app_font') || 'Inter';
}

const hash = new URL(window.location.href).hash;
const params = new URLSearchParams(hash.substring(2));

return params.get('font') || 'Inter';
};

const font = getFont();
const font = localStorage.getItem('app_font') || 'Inter';

const cache = createCache({
key: 'css',
Expand Down
4 changes: 2 additions & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const LANGUAGE_LIST = [
{ code: 't', locale: 'pt-BR', name: 'Português (Brasil)' },
{ code: 'u', locale: 'ru-RU', name: 'русский' },
{ code: 'm', locale: 'ro-RO', name: 'Română' },
{ code: 'tg', locale: 'tl-PH', name: 'Tagalog' },
{ code: 'tg', locale: 'tl-PH', name: 'Tagalog', identifier: 'tgl' },
{
code: 'tnd',
locale: 'mg-TND',
Expand Down Expand Up @@ -65,7 +65,7 @@ export const LANGUAGE_LIST = [
{ code: 'cv', locale: 'ceb-PH', name: 'Cebuano' },
{ code: 'kha', locale: 'mn-MN', name: 'монгол' },
{ code: 'rea', locale: 'hy-AM', name: 'Հայերեն' },
{ code: 'h', locale: 'hy-HU', name: 'magyar' },
{ code: 'h', locale: 'hu-HU', name: 'magyar' },
{ code: 'tpo', locale: 'pt-PT', name: 'Português (Portugal)' },
{ code: 'fi', locale: 'fi-FI', name: 'suomi' },
{ code: 'st', locale: 'et-EE', name: 'eesti' },
Expand Down
1 change: 0 additions & 1 deletion src/definition/ministry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export type APRecordType = {
};

export type IncomingReport = {
report_id: string;
person_uid: string;
bible_studies: number;
comments: string;
Expand Down
39 changes: 19 additions & 20 deletions src/features/app_notification/container/useContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ import {
dbVisitingSpeakersUpdateRemote,
decryptVisitingSpeakers,
} from '@services/dexie/visiting_speakers';
import {
accountTypeState,
congAccessCodeState,
congMasterKeyState,
} from '@states/settings';
import { accountTypeState } from '@states/settings';
import { decryptData, decryptObject } from '@services/encryption';
import { displaySnackNotification } from '@services/recoil/app';
import { getMessageByCode } from '@services/i18n/translation';
Expand All @@ -37,6 +33,7 @@ import usePendingRequests from './usePendingRequests';
import useRemoteNotifications from './useRemoteNotifications';
import useUnverifiedReports from './useUnverifiedReports';
import { apiFetchNotifications } from '@services/api/notification';
import appDb from '@db/appDb';

const useContainer = () => {
const { t } = useAppTranslation();
Expand All @@ -61,12 +58,11 @@ const useContainer = () => {
const congregationsNotDisapproved = useRecoilValue(
congregationsNotDisapprovedState
);
const congMasterKey = useRecoilValue(congMasterKeyState);
const congAccessCode = useRecoilValue(congAccessCodeState);

const accountType = useRecoilValue(accountTypeState);
const userID = useRecoilValue(userIDState);

const { data, isPending } = useQuery({
const { data, isFetching } = useQuery({
enabled:
userID.length > 0 &&
accountType === 'vip' &&
Expand Down Expand Up @@ -160,6 +156,9 @@ const useContainer = () => {
);

if (foundCong) {
const settings = await appDb.app_settings.get(1);
const congMasterKey = settings.cong_settings.cong_master_key;

const masterKey = decryptData(
data.result.cong_master_key,
congMasterKey
Expand All @@ -184,14 +183,7 @@ const useContainer = () => {
severity: 'error',
});
}
}, [
data,
pendingRequests,
setNotifications,
t,
congregationRemotes,
congMasterKey,
]);
}, [data, pendingRequests, setNotifications, t, congregationRemotes]);

const handleRejectedRequests = useCallback(async () => {
try {
Expand Down Expand Up @@ -276,6 +268,9 @@ const useContainer = () => {

if (!incoming) return;

const settings = await appDb.app_settings.get(1);
const congAccessCode = settings.cong_settings.cong_access_code;

const remoteAccessCode = data.result.cong_access_code;
const accessCode = decryptData(remoteAccessCode, congAccessCode);

Expand All @@ -295,7 +290,7 @@ const useContainer = () => {
severity: 'error',
});
}
}, [data, congAccessCode, setApplications]);
}, [data, setApplications]);

const handleUnauthorized = useCallback(async () => {
const status = data?.status;
Expand All @@ -311,6 +306,9 @@ const useContainer = () => {

if (!incoming) return;

const settings = await appDb.app_settings.get(1);
const congAccessCode = settings.cong_settings.cong_access_code;

const remoteAccessCode = data.result.cong_access_code;
const accessCode = decryptData(remoteAccessCode, congAccessCode);

Expand All @@ -330,10 +328,10 @@ const useContainer = () => {
severity: 'error',
});
}
}, [data, congAccessCode]);
}, [data]);

useEffect(() => {
if (!isPending) {
if (!isFetching) {
handleUnauthorized();

handlePendingSpeakersRequests();
Expand All @@ -349,7 +347,8 @@ const useContainer = () => {
checkUnverifiedReports();
}
}, [
isPending,
data,
isFetching,
handleUnauthorized,
handlePendingSpeakersRequests,
handleRemoteCongregations,
Expand Down
4 changes: 3 additions & 1 deletion src/features/app_start/shared/hooks/useFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const useFeedback = () => {
document.querySelector<HTMLElement>('#onboarding-error');

const hideMessage = () => {
onboardingError.style.animation = 'fade-out 0.15s forwards';
if (onboardingError) {
onboardingError.style.animation = 'fade-out 0.15s forwards';
}
};

const showMessage = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const useCongregationAccessCode = () => {

await dbAppSettingsUpdate({
'cong_settings.cong_access_code': tmpAccessCode,
'cong_settings.cong_new': true,
});

setIsSetup(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const useCongregationDetails = () => {
'cong_settings.cong_circuit': result.cong_settings.cong_circuit,
'cong_settings.midweek_meeting': midweekMeeting,
'cong_settings.weekend_meeting': weekendMeeting,
'cong_settings.cong_new': true,
});

await setIsNewCongregation(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const useCongregationMasterKey = () => {

await dbAppSettingsUpdate({
'cong_settings.cong_master_key': tmpMasterKey,
'cong_settings.cong_new': true,
});

setCurrentStep(2);
Expand Down
26 changes: 19 additions & 7 deletions src/features/app_start/vip/startup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@ const VipStartup = () => {
{!isCongCreate && !isEncryptionCodeOpen && isLoading && (
<WaitingLoader type="lottie" variant="standard" />
)}
{isUserSignIn && <Signin />}
{isUserMfaVerify && <VerifyMFA />}
{isUserAccountCreated && <UserAccountCreated />}
{isCongCreate && <CongregationCreate />}
{isEmailAuth && <EmailAuth />}
{isEmailLinkAuth && <EmailLinkAuthentication />}
{isEncryptionCodeOpen && <CongregationEncryption />}

{!isLoading && (
<>
{isUserSignIn && <Signin />}

{!isUserSignIn && (
<>
{isUserMfaVerify && <VerifyMFA />}
{isUserAccountCreated && <UserAccountCreated />}
{isCongCreate && <CongregationCreate />}
{isEmailAuth && <EmailAuth />}
{isEmailLinkAuth && <EmailLinkAuthentication />}
{!isCongCreate && isEncryptionCodeOpen && (
<CongregationEncryption />
)}
</>
)}
</>
)}
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/features/app_start/vip/startup/useStartup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const useStartup = () => {
return;
}

if (congAccessCode.length === 0) {
if (congAccessCode.length === 0 && congName.length > 0) {
setIsStart(false);
setIsEncryptionCodeOpen(true);
}
Expand Down
27 changes: 4 additions & 23 deletions src/features/language_switcher/useLanguage.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import { useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { useBreakpoints } from '@hooks/index';
import { cookiesConsentState, isAppLoadState } from '@states/app';
import { isAppLoadState } from '@states/app';
import { LANGUAGE_LIST } from '@constants/index';
import { getTranslation } from '@services/i18n/translation';
import { FullnameOption } from '@definition/settings';
import { dbAppSettingsUpdate } from '@services/dexie/settings';
import {
accountTypeState,
settingsState,
userDataViewState,
} from '@states/settings';
import { settingsState, userDataViewState } from '@states/settings';

const useLanguage = () => {
const { tabletDown } = useBreakpoints();

const [, setParams] = useSearchParams();

const isAppLoad = useRecoilValue(isAppLoadState);
const dataView = useRecoilValue(userDataViewState);
const settings = useRecoilValue(settingsState);
const cookiesConsent = useRecoilValue(cookiesConsentState);
const accountType = useRecoilValue(accountTypeState);

const [anchorEl, setAnchorEl] = useState(null);
const isMenuOpen = Boolean(anchorEl);
Expand All @@ -45,18 +36,8 @@ const useLanguage = () => {
const font =
LANGUAGE_LIST.find((lang) => lang.locale === ui_lang)?.font || 'Inter';

if (cookiesConsent || accountType === 'pocket') {
localStorage.setItem('ui_lang', ui_lang);
localStorage.setItem('app_font', font);
}

if (!cookiesConsent && accountType !== 'pocket') {
setParams((params) => {
params.set('locale', ui_lang);
params.set('font', font);
return params;
});
}
localStorage.setItem('ui_lang', ui_lang);
localStorage.setItem('app_font', font);
rhahao marked this conversation as resolved.
Show resolved Hide resolved

handleClose();
window.location.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { useMemo, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { useAppTranslation, useIntersectionObserver } from '@hooks/index';
import { schedulesState } from '@states/schedules';
import { addMonths, getWeekDate } from '@utils/date';
import { addMonths, generateDateFromTime, getWeekDate } from '@utils/date';
import { formatDate } from '@services/dateformat';
import {
hour24FormatState,
midweekMeetingClassCountState,
midweekMeetingOpeningPrayerAutoAssign,
midweekMeetingTimeState,
Expand Down Expand Up @@ -38,6 +39,7 @@ const useMidweekMeeting = () => {
const userUID = useRecoilValue(userLocalUIDState);
const pgmStart = useRecoilValue(midweekMeetingTimeState);
const lang = useRecoilValue(JWLangState);
const use24 = useRecoilValue(hour24FormatState);
const openingPrayerAuto = useRecoilValue(
midweekMeetingOpeningPrayerAutoAssign
);
Expand Down Expand Up @@ -168,16 +170,23 @@ const useMidweekMeeting = () => {
const partTimings = useMemo(() => {
if (!schedule && !source) return;

let meetingStart = pgmStart;

if (!use24) {
const date = generateDateFromTime(pgmStart);
meetingStart = formatDate(date, 'h:mm');
}

const result = schedulesMidweekGetTiming({
schedule,
dataView,
pgmStart,
pgmStart: meetingStart,
source,
lang,
});

return result;
}, [schedule, source, dataView, pgmStart, lang]);
}, [schedule, source, dataView, pgmStart, lang, use24]);

const handleGoCurrent = () => {
const now = getWeekDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import { useMemo, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { useAppTranslation, useIntersectionObserver } from '@hooks/index';
import { schedulesState } from '@states/schedules';
import { addMonths, getWeekDate, timeAddMinutes } from '@utils/date';
import {
addMonths,
generateDateFromTime,
getWeekDate,
timeAddMinutes,
} from '@utils/date';
import { formatDate } from '@services/dateformat';
import {
hour24FormatState,
userDataViewState,
userLocalUIDState,
weekendMeetingOpeningPrayerAutoAssignState,
Expand Down Expand Up @@ -39,6 +45,7 @@ const useWeekendMeeting = () => {
const sources = useRecoilValue(sourcesState);
const userUID = useRecoilValue(userLocalUIDState);
const pgmStart = useRecoilValue(weekendMeetingTimeState);
const use24 = useRecoilValue(hour24FormatState);
const openingPrayerAuto = useRecoilValue(
weekendMeetingOpeningPrayerAutoAssignState
);
Expand Down Expand Up @@ -179,7 +186,14 @@ const useWeekendMeeting = () => {
const partTimings = useMemo(() => {
const timings = {} as WeekendMeetingTimingsType;

timings.pgm_start = timeAddMinutes(pgmStart, 0);
let meetingStart = pgmStart;

if (!use24) {
const date = generateDateFromTime(pgmStart);
meetingStart = formatDate(date, 'h:mm');
}

timings.pgm_start = timeAddMinutes(meetingStart, 0);
timings.public_talk = timeAddMinutes(timings.pgm_start, 5);
timings.middle_song = timeAddMinutes(timings.public_talk, 30);
timings.w_study = timeAddMinutes(timings.middle_song, 5);
Expand All @@ -194,7 +208,7 @@ const useWeekendMeeting = () => {
}

return timings;
}, [pgmStart, weekType]);
}, [pgmStart, weekType, use24]);

const handleGoCurrent = () => {
const now = getWeekDate();
Expand Down
Loading
Loading