commit
52e2a14c56
|
@ -134,7 +134,8 @@ export default function Upload(props: Props) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const paths: string[] = props.acceptedFiles.map((file) => file['path']);
|
const paths: string[] = props.acceptedFiles.map((file) => file['path']);
|
||||||
paths.sort();
|
const getCharCount = (str: string) => (str.match(/\//g) ?? []).length;
|
||||||
|
paths.sort((path1, path2) => getCharCount(path1) - getCharCount(path2));
|
||||||
const firstPath = paths[0];
|
const firstPath = paths[0];
|
||||||
const lastPath = paths[paths.length - 1];
|
const lastPath = paths[paths.length - 1];
|
||||||
const L = firstPath.length;
|
const L = firstPath.length;
|
||||||
|
|
|
@ -479,6 +479,8 @@ type AppContextType = {
|
||||||
sharedFiles: File[];
|
sharedFiles: File[];
|
||||||
resetSharedFiles: () => void;
|
resetSharedFiles: () => void;
|
||||||
setDisappearingFlashMessage: (message: FlashMessage) => void;
|
setDisappearingFlashMessage: (message: FlashMessage) => void;
|
||||||
|
redirectUrl: string;
|
||||||
|
setRedirectUrl: (url: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum FLASH_MESSAGE_TYPE {
|
export enum FLASH_MESSAGE_TYPE {
|
||||||
|
@ -508,6 +510,7 @@ export default function App({ Component, err }) {
|
||||||
const [sharedFiles, setSharedFiles] = useState<File[]>(null);
|
const [sharedFiles, setSharedFiles] = useState<File[]>(null);
|
||||||
const [redirectName, setRedirectName] = useState<string>(null);
|
const [redirectName, setRedirectName] = useState<string>(null);
|
||||||
const [flashMessage, setFlashMessage] = useState<FlashMessage>(null);
|
const [flashMessage, setFlashMessage] = useState<FlashMessage>(null);
|
||||||
|
const [redirectUrl, setRedirectUrl] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
!('serviceWorker' in navigator) ||
|
!('serviceWorker' in navigator) ||
|
||||||
|
@ -641,6 +644,8 @@ export default function App({ Component, err }) {
|
||||||
sharedFiles,
|
sharedFiles,
|
||||||
resetSharedFiles,
|
resetSharedFiles,
|
||||||
setDisappearingFlashMessage,
|
setDisappearingFlashMessage,
|
||||||
|
redirectUrl,
|
||||||
|
setRedirectUrl,
|
||||||
}}>
|
}}>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<Container>
|
<Container>
|
||||||
|
|
|
@ -75,8 +75,9 @@ export default function Credentials() {
|
||||||
}
|
}
|
||||||
await SaveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key);
|
await SaveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key);
|
||||||
await decryptAndStoreToken(key);
|
await decryptAndStoreToken(key);
|
||||||
|
const redirectUrl = appContext.redirectUrl;
|
||||||
router.push(PAGES.GALLERY);
|
appContext.setRedirectUrl(null);
|
||||||
|
router.push(redirectUrl ?? PAGES.GALLERY);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError(e, 'user entered a wrong password');
|
logError(e, 'user entered a wrong password');
|
||||||
setFieldError('passphrase', constants.INCORRECT_PASSPHRASE);
|
setFieldError('passphrase', constants.INCORRECT_PASSPHRASE);
|
||||||
|
|
|
@ -211,9 +211,11 @@ export default function Gallery() {
|
||||||
const [fixCreationTimeView, setFixCreationTimeView] = useState(false);
|
const [fixCreationTimeView, setFixCreationTimeView] = useState(false);
|
||||||
const [fixCreationTimeAttributes, setFixCreationTimeAttributes] =
|
const [fixCreationTimeAttributes, setFixCreationTimeAttributes] =
|
||||||
useState<FixCreationTimeAttributes>(null);
|
useState<FixCreationTimeAttributes>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
|
const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
|
appContext.setRedirectUrl(router.asPath);
|
||||||
router.push(PAGES.ROOT);
|
router.push(PAGES.ROOT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -233,11 +235,6 @@ export default function Gallery() {
|
||||||
setCollections(collections);
|
setCollections(collections);
|
||||||
setTrash(trash);
|
setTrash(trash);
|
||||||
await setDerivativeState(collections, files);
|
await setDerivativeState(collections, files);
|
||||||
await checkSubscriptionPurchase(
|
|
||||||
setDialogMessage,
|
|
||||||
router,
|
|
||||||
setLoading
|
|
||||||
);
|
|
||||||
await syncWithRemote(true);
|
await syncWithRemote(true);
|
||||||
setIsFirstLoad(false);
|
setIsFirstLoad(false);
|
||||||
setJustSignedUp(false);
|
setJustSignedUp(false);
|
||||||
|
@ -282,6 +279,13 @@ export default function Gallery() {
|
||||||
router.push(href, undefined, { shallow: true });
|
router.push(href, undefined, { shallow: true });
|
||||||
}, [activeCollection]);
|
}, [activeCollection]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
|
||||||
|
if (router.isReady && key) {
|
||||||
|
checkSubscriptionPurchase(setDialogMessage, router, setLoading);
|
||||||
|
}
|
||||||
|
}, [router.isReady]);
|
||||||
|
|
||||||
const syncWithRemote = async (force = false, silent = false) => {
|
const syncWithRemote = async (force = false, silent = false) => {
|
||||||
if (syncInProgress.current && !force) {
|
if (syncInProgress.current && !force) {
|
||||||
resync.current = true;
|
resync.current = true;
|
||||||
|
|
|
@ -134,6 +134,10 @@ class billingService {
|
||||||
sessionID: string = null
|
sessionID: string = null
|
||||||
): Promise<Subscription> {
|
): Promise<Subscription> {
|
||||||
try {
|
try {
|
||||||
|
const token = getToken();
|
||||||
|
if (!token) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const response = await HTTPService.post(
|
const response = await HTTPService.post(
|
||||||
`${ENDPOINT}/billing/verify-subscription`,
|
`${ENDPOINT}/billing/verify-subscription`,
|
||||||
{
|
{
|
||||||
|
@ -143,7 +147,7 @@ class billingService {
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
'X-Auth-Token': getToken(),
|
'X-Auth-Token': token,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const { subscription } = response.data;
|
const { subscription } = response.data;
|
||||||
|
|
|
@ -19,6 +19,8 @@ class FFmpegService {
|
||||||
this.isLoading = null;
|
this.isLoading = null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError(e, 'ffmpeg load failed');
|
logError(e, 'ffmpeg load failed');
|
||||||
|
this.ffmpeg = null;
|
||||||
|
this.isLoading = null;
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ export async function generateThumbnail(
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError(e, 'failed to generate thumbnail using ffmpeg', {
|
logError(e, 'failed to generate thumbnail using ffmpeg', {
|
||||||
type: fileTypeInfo.exactType,
|
fileFormat: fileTypeInfo.exactType,
|
||||||
});
|
});
|
||||||
canvas = await generateVideoThumbnail(file);
|
canvas = await generateVideoThumbnail(file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,17 +191,14 @@ export async function checkSubscriptionPurchase(
|
||||||
router: NextRouter,
|
router: NextRouter,
|
||||||
setLoading: SetLoading
|
setLoading: SetLoading
|
||||||
) {
|
) {
|
||||||
|
const { session_id: sessionId, status, reason } = router.query ?? {};
|
||||||
try {
|
try {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const sessionId = urlParams.get('session_id');
|
|
||||||
const status = urlParams.get('status');
|
|
||||||
const reason = urlParams.get('reason');
|
|
||||||
if (status === RESPONSE_STATUS.fail) {
|
if (status === RESPONSE_STATUS.fail) {
|
||||||
handleFailureReason(reason, setDialogMessage, setLoading);
|
handleFailureReason(reason as string, setDialogMessage, setLoading);
|
||||||
} else if (status === RESPONSE_STATUS.success) {
|
} else if (status === RESPONSE_STATUS.success) {
|
||||||
try {
|
try {
|
||||||
const subscription = await billingService.verifySubscription(
|
const subscription = await billingService.verifySubscription(
|
||||||
sessionId
|
sessionId as string
|
||||||
);
|
);
|
||||||
setDialogMessage({
|
setDialogMessage({
|
||||||
title: constants.SUBSCRIPTION_PURCHASE_SUCCESS_TITLE,
|
title: constants.SUBSCRIPTION_PURCHASE_SUCCESS_TITLE,
|
||||||
|
@ -220,8 +217,6 @@ export async function checkSubscriptionPurchase(
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
} finally {
|
|
||||||
router.push('gallery', undefined, { shallow: true });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue