Merge pull request #248 from ente-io/master

release
This commit is contained in:
abhinavkgrd 2021-11-25 12:14:00 +05:30 committed by GitHub
commit 52e2a14c56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 18 deletions

View file

@ -134,7 +134,8 @@ export default function Upload(props: Props) {
return null;
}
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 lastPath = paths[paths.length - 1];
const L = firstPath.length;

View file

@ -479,6 +479,8 @@ type AppContextType = {
sharedFiles: File[];
resetSharedFiles: () => void;
setDisappearingFlashMessage: (message: FlashMessage) => void;
redirectUrl: string;
setRedirectUrl: (url: string) => void;
};
export enum FLASH_MESSAGE_TYPE {
@ -508,6 +510,7 @@ export default function App({ Component, err }) {
const [sharedFiles, setSharedFiles] = useState<File[]>(null);
const [redirectName, setRedirectName] = useState<string>(null);
const [flashMessage, setFlashMessage] = useState<FlashMessage>(null);
const [redirectUrl, setRedirectUrl] = useState(null);
useEffect(() => {
if (
!('serviceWorker' in navigator) ||
@ -641,6 +644,8 @@ export default function App({ Component, err }) {
sharedFiles,
resetSharedFiles,
setDisappearingFlashMessage,
redirectUrl,
setRedirectUrl,
}}>
{loading ? (
<Container>

View file

@ -75,8 +75,9 @@ export default function Credentials() {
}
await SaveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key);
await decryptAndStoreToken(key);
router.push(PAGES.GALLERY);
const redirectUrl = appContext.redirectUrl;
appContext.setRedirectUrl(null);
router.push(redirectUrl ?? PAGES.GALLERY);
} catch (e) {
logError(e, 'user entered a wrong password');
setFieldError('passphrase', constants.INCORRECT_PASSPHRASE);

View file

@ -211,9 +211,11 @@ export default function Gallery() {
const [fixCreationTimeView, setFixCreationTimeView] = useState(false);
const [fixCreationTimeAttributes, setFixCreationTimeAttributes] =
useState<FixCreationTimeAttributes>(null);
useEffect(() => {
const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
if (!key) {
appContext.setRedirectUrl(router.asPath);
router.push(PAGES.ROOT);
return;
}
@ -233,11 +235,6 @@ export default function Gallery() {
setCollections(collections);
setTrash(trash);
await setDerivativeState(collections, files);
await checkSubscriptionPurchase(
setDialogMessage,
router,
setLoading
);
await syncWithRemote(true);
setIsFirstLoad(false);
setJustSignedUp(false);
@ -282,6 +279,13 @@ export default function Gallery() {
router.push(href, undefined, { shallow: true });
}, [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) => {
if (syncInProgress.current && !force) {
resync.current = true;

View file

@ -134,6 +134,10 @@ class billingService {
sessionID: string = null
): Promise<Subscription> {
try {
const token = getToken();
if (!token) {
return;
}
const response = await HTTPService.post(
`${ENDPOINT}/billing/verify-subscription`,
{
@ -143,7 +147,7 @@ class billingService {
},
null,
{
'X-Auth-Token': getToken(),
'X-Auth-Token': token,
}
);
const { subscription } = response.data;

View file

@ -19,6 +19,8 @@ class FFmpegService {
this.isLoading = null;
} catch (e) {
logError(e, 'ffmpeg load failed');
this.ffmpeg = null;
this.isLoading = null;
throw e;
}
}

View file

@ -44,7 +44,7 @@ export async function generateThumbnail(
);
} catch (e) {
logError(e, 'failed to generate thumbnail using ffmpeg', {
type: fileTypeInfo.exactType,
fileFormat: fileTypeInfo.exactType,
});
canvas = await generateVideoThumbnail(file);
}

View file

@ -191,17 +191,14 @@ export async function checkSubscriptionPurchase(
router: NextRouter,
setLoading: SetLoading
) {
const { session_id: sessionId, status, reason } = router.query ?? {};
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) {
handleFailureReason(reason, setDialogMessage, setLoading);
handleFailureReason(reason as string, setDialogMessage, setLoading);
} else if (status === RESPONSE_STATUS.success) {
try {
const subscription = await billingService.verifySubscription(
sessionId
sessionId as string
);
setDialogMessage({
title: constants.SUBSCRIPTION_PURCHASE_SUCCESS_TITLE,
@ -220,8 +217,6 @@ export async function checkSubscriptionPurchase(
}
} catch (e) {
// ignore
} finally {
router.push('gallery', undefined, { shallow: true });
}
}