Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

temp

Abhinava33850c41892
diff --git a/apps/photos/public/locales/en/translation.json b/apps/photos/public/locales/en/translation.json
index 9c97bc1064..4e12425012 100644
--- a/apps/photos/public/locales/en/translation.json
+++ b/apps/photos/public/locales/en/translation.json
@@ -38,8 +38,8 @@
"KEY_GENERATION_IN_PROGRESS_MESSAGE": "Generating encryption keys...",
"PASSPHRASE_HINT": "Password",
"CONFIRM_PASSPHRASE": "Confirm password",
- "REFERRAL_CODE_HINT":"How did you hear about Ente? (optional)",
- "REFERRAL_INFO":"We don't track app installs, It'd help us if you told us where you found us!",
+ "REFERRAL_CODE_HINT": "How did you hear about Ente? (optional)",
+ "REFERRAL_INFO": "We don't track app installs, It'd help us if you told us where you found us!",
"PASSPHRASE_MATCH_ERROR": "Passwords don't match",
"CONSOLE_WARNING_STOP": "STOP!",
"CONSOLE_WARNING_DESC": "This is a browser feature intended for developers. Please don't copy-paste unverified code here.",
@@ -620,8 +620,9 @@
"ROTATION": "Rotation",
"RESET": "Reset",
"PHOTO_EDITOR": "Photo Editor",
- "FASTER_UPLOAD":"Faster uploads",
- "FASTER_UPLOAD_DESCRIPTION":"Route uploads through nearby servers",
+ "FASTER_UPLOAD": "Faster uploads",
+ "FASTER_UPLOAD_DESCRIPTION": "Route uploads through nearby servers",
"STATUS": "Status",
- "INDEXED_ITEMS": "Indexed items"
+ "INDEXED_ITEMS": "Indexed items",
+ "CUSTOM_CACHE_DIRECTORY": "Cache folder"
}
diff --git a/apps/photos/src/components/ExportModal.tsx b/apps/photos/src/components/ExportModal.tsx
index 9e9521675d..a6e3e1aec0 100644
--- a/apps/photos/src/components/ExportModal.tsx
+++ b/apps/photos/src/components/ExportModal.tsx
@@ -35,7 +35,7 @@ import { CustomError } from '@ente/shared/error';
import { addLogLine } from '@ente/shared/logging';
import { EnteFile } from 'types/file';
-const ExportFolderPathContainer = styled(LinkButton)`
+export const ExportFolderPathContainer = styled(LinkButton)`
width: 262px;
white-space: nowrap;
overflow: hidden;
@@ -269,7 +269,7 @@ function ExportDirectory({
);
}
-function ExportDirectoryOption({ changeExportDirectory }) {
+export function ExportDirectoryOption({ changeExportDirectory }) {
return (
<OverflowMenu
triggerButtonProps={{
diff --git a/apps/photos/src/components/Sidebar/Preferences/index.tsx b/apps/photos/src/components/Sidebar/Preferences/index.tsx
index ad158c66ce..5369c0e506 100644
--- a/apps/photos/src/components/Sidebar/Preferences/index.tsx
+++ b/apps/photos/src/components/Sidebar/Preferences/index.tsx
@@ -1,9 +1,9 @@
import ChevronRight from '@mui/icons-material/ChevronRight';
-import { Box, DialogProps, Stack } from '@mui/material';
+import { Box, Button, DialogProps, Stack, Tooltip } from '@mui/material';
import { EnteDrawer } from 'components/EnteDrawer';
import Titlebar from 'components/Titlebar';
import isElectron from 'is-electron';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import { t } from 'i18next';
import AdvancedSettings from '../AdvancedSettings';
@@ -15,6 +15,10 @@ import { useLocalState } from '@ente/shared/hooks/useLocalState';
import ElectronAPIs from '@ente/shared/electron';
import InMemoryStore, { MS_KEYS } from '@ente/shared/storage/InMemoryStore';
import { logError } from '@ente/shared/sentry';
+import { ExportDirectoryOption } from 'components/ExportModal';
+import { MenuItemGroup } from 'components/Menu/MenuItemGroup';
+import MenuSectionTitle from 'components/Menu/MenuSectionTitle';
+import { addLogLine } from '@ente/shared/logging';
export default function Preferences({ open, onClose, onRootClose }) {
const [advancedSettingsView, setAdvancedSettingsView] = useState(false);
@@ -23,6 +27,21 @@ export default function Preferences({ open, onClose, onRootClose }) {
LS_KEYS.OPT_OUT_OF_CRASH_REPORTS,
false
);
+ const [customCacheDirectory, setCustomCacheDirectory] = useLocalState(
+ LS_KEYS.CUSTOM_CACHE_DIRECTORY,
+ undefined
+ );
+
+ useEffect(() => {
+ const main = async () => {
+ if (isElectron()) {
+ const customCacheDirectory =
+ await ElectronAPIs.getCustomCacheDirectory();
+ setCustomCacheDirectory(customCacheDirectory);
+ }
+ };
+ main();
+ }, []);
const openAdvancedSettings = () => setAdvancedSettingsView(true);
const closeAdvancedSettings = () => setAdvancedSettingsView(false);
@@ -60,6 +79,23 @@ export default function Preferences({ open, onClose, onRootClose }) {
}
};
+ const handleCustomCacheDirectoryChange = async () => {
+ try {
+ if (!isElectron()) {
+ return;
+ }
+ const newFolder = await ElectronAPIs.selectDirectory();
+ if (!newFolder) {
+ return;
+ }
+ addLogLine(`Export folder changed to ${newFolder}`);
+ await ElectronAPIs.setCustomCacheDirectory(newFolder);
+ setCustomCacheDirectory(newFolder);
+ } catch (e) {
+ logError(e, 'changeCustomCacheDirectory failed');
+ }
+ };
+
return (
<EnteDrawer
transitionDuration={0}
@@ -82,7 +118,34 @@ export default function Preferences({ open, onClose, onRootClose }) {
checked={!optOutOfCrashReports}
onClick={toggleOptOutOfCrashReports}
label={t('CRASH_REPORTING')}
- />{' '}
+ />
+
+ <Box>
+ <MenuSectionTitle
+ title={t('CUSTOM_CACHE_DIRECTORY')}
+ />
+ <MenuItemGroup>
+ {customCacheDirectory ? (
+ <Tooltip title={customCacheDirectory}>
+ <span>{customCacheDirectory}</span>
+ </Tooltip>
+ ) : (
+ <Button
+ color={'accent'}
+ onClick={
+ handleCustomCacheDirectoryChange
+ }>
+ {t('SELECT_FOLDER')}
+ </Button>
+ )}
+ <ExportDirectoryOption
+ changeExportDirectory={
+ handleCustomCacheDirectoryChange
+ }
+ />
+ </MenuItemGroup>
+ </Box>
+
<EnteMenuItem
onClick={openMapSettings}
endIcon={<ChevronRight />}
diff --git a/packages/shared/electron/types.ts b/packages/shared/electron/types.ts
index 883997a021..12b127ac72 100644
--- a/packages/shared/electron/types.ts
+++ b/packages/shared/electron/types.ts
@@ -100,4 +100,6 @@ export interface ElectronAPIsType {
computeImageEmbedding: (imageData: Uint8Array) => Promise<Float32Array>;
computeTextEmbedding: (text: string) => Promise<Float32Array>;
getPlatform: () => Promise<'mac' | 'windows' | 'linux'>;
+ setCustomCacheDirectory: (directory: string) => Promise<void>;
+ getCustomCacheDirectory: () => Promise<string>;
}
diff --git a/packages/shared/storage/localStorage/index.ts b/packages/shared/storage/localStorage/index.ts
index 5dc7ce5caf..764597f2d4 100644
--- a/packages/shared/storage/localStorage/index.ts
+++ b/packages/shared/storage/localStorage/index.ts
@@ -28,6 +28,7 @@ export enum LS_KEYS {
OPT_OUT_OF_CRASH_REPORTS = 'optOutOfCrashReports',
CF_PROXY_DISABLED = 'cfProxyDisabled',
REFERRAL_SOURCE = 'referralSource',
+ CUSTOM_CACHE_DIRECTORY = 'customCacheDirectory',
}
export const setData = (key: LS_KEYS, value: object) => {