Skip to content

Commit

Permalink
Include exporting of shared files on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
Trekky12 committed Sep 17, 2024
1 parent f4995cb commit aa8898a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
43 changes: 43 additions & 0 deletions web/apps/photos/src/components/ExportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function ExportModal(props: Props) {
});
const [pendingExports, setPendingExports] = useState<EnteFile[]>([]);
const [lastExportTime, setLastExportTime] = useState(0);
const [includeShared, setIncludeShared] = useState(false);

// ====================
// SIDE EFFECTS
Expand All @@ -68,6 +69,7 @@ export default function ExportModal(props: Props) {
exportService.getExportSettings();
setExportFolder(exportSettings?.folder ?? null);
setContinuousExport(exportSettings?.continuousExport ?? false);
setIncludeShared(exportSettings?.includeShared ?? false);
void syncExportRecord(exportSettings?.folder);
} catch (e) {
log.error("export on mount useEffect failed", e);
Expand Down Expand Up @@ -145,6 +147,20 @@ export default function ExportModal(props: Props) {
setContinuousExport(newContinuousExport);
};

const toggleIncludeShared = async () => {
const newIncludeShared = !includeShared;
exportService.updateExportSettings({
includeShared: newIncludeShared,
});
setIncludeShared(newIncludeShared);

const exportRecord =
await exportService.getExportRecord(exportFolder);
const pendingExports =
await exportService.getPendingExports(exportRecord);
setPendingExports(pendingExports);
};

const startExport = async (opts?: ExportOpts) => {
if (!(await verifyExportFolderExists())) return;

Expand All @@ -171,6 +187,11 @@ export default function ExportModal(props: Props) {
changeExportDirectory={handleChangeExportDirectoryClick}
exportStage={exportStage}
/>
<IncludeShared
exportStage={exportStage}
includeShared={includeShared}
toggleIncludeShared={toggleIncludeShared}
/>
<ContinuousExport
continuousExport={continuousExport}
toggleContinuousExport={toggleContinuousExport}
Expand Down Expand Up @@ -235,6 +256,28 @@ function ContinuousExport({ continuousExport, toggleContinuousExport }) {
);
}

function IncludeShared({ exportStage, includeShared, toggleIncludeShared }) {
switch (exportStage) {
case ExportStage.INIT:
case ExportStage.FINISHED:
return (
<SpaceBetweenFlex minHeight={"48px"}>
<Typography color="text.muted">{t("INCLUDE_SHARED")}</Typography>
<Box>
<EnteSwitch
color="accent"
checked={includeShared}
onChange={toggleIncludeShared}
/>
</Box>
</SpaceBetweenFlex>
);

default:
return <></>;
}
}

const ExportDynamicContent = ({
exportStage,
startExport,
Expand Down
8 changes: 6 additions & 2 deletions web/apps/photos/src/services/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ class ExportService {
collection.owner.id,
]),
);
const userPersonalFiles = getPersonalFiles(

const includeShared = this.getExportSettings()?.includeShared;
const userPersonalFiles = includeShared ? files : getPersonalFiles(
files,
user,
collectionIdToOwnerIDMap,
Expand Down Expand Up @@ -348,7 +350,9 @@ class ExportService {
collection.owner.id,
]),
);
const personalFiles = getPersonalFiles(

const includeShared = this.getExportSettings()?.includeShared;
const personalFiles = includeShared ? files : getPersonalFiles(
files,
user,
collectionIdToOwnerIDMap,
Expand Down
1 change: 1 addition & 0 deletions web/apps/photos/src/types/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface ExportRecord {
export interface ExportSettings {
folder: string;
continuousExport: boolean;
includeShared: boolean;
}

export interface ExportUIUpdaters {
Expand Down
1 change: 1 addition & 0 deletions web/packages/base/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@
"CONTINUOUS_EXPORT": "Sync continuously",
"PENDING_ITEMS": "Pending items",
"EXPORT_STARTING": "Export starting...",
"INCLUDE_SHARED": "Include shared files",
"delete_account_reason_label": "What is the main reason you are deleting your account?",
"delete_account_reason_placeholder": "Select a reason",
"delete_reason": {
Expand Down

0 comments on commit aa8898a

Please sign in to comment.