Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/img/icon/settings/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/img/icon/settings/drive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/img/icon/settings/location.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/img/theme/dark/icon/settings/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/json/text.json
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,10 @@
"popupSettingsDataLocalFiles": "Local files",
"popupSettingsDataOffloadWarningText": "All media files stored <b>in Anytype</b> will be deleted from your current device. They can be downloaded again from a backup node or another device.",
"popupSettingsDataOffloadWarningTextLocalOnly": "Be careful: your client is in local-only mode, and data is not backing up to external nodes. Ensure that your files are synced to your other devices before removing them.",

"popupSettingsDataOfflineAccess": "Offline Access",
"popupSettingsDataOfflineAccessDescription": "Auto sync files up to 20 MB for offline access",

"popupSettingsDataFilesOffloaded": "Files offloaded",
"popupSettingsDataKeepFiles": "Keep files",
"popupSettingsDataRemoveFiles": "Remove files",
Expand Down
2 changes: 1 addition & 1 deletion src/scss/page/main/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@
background-position: 50% 50%; background-repeat: no-repeat; background-size: 24px; background-color: var(--color-shape-highlight-medium);
}
.icon.drive { background-image: url('~img/icon/settings/drive.svg'); }
.icon.sites { background-image: url('~img/icon/settings/sites.svg'); }
.icon.location { background-image: url('~img/icon/settings/location.svg'); }
.icon.download { background-image: url('~img/icon/settings/download.svg'); }

.actionItems {
.title { @include text-common; font-weight: 400; margin-bottom: 0; }
Expand Down
2 changes: 1 addition & 1 deletion src/scss/theme/dark/page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@

.pageSettingsDataIndex {
.icon.drive { background-image: url('#{$themePath}/icon/settings/drive.svg'); }
.icon.sites { background-image: url('#{$themePath}/icon/settings/sites.svg'); }
.icon.location { background-image: url('#{$themePath}/icon/settings/location.svg'); }
.icon.download { background-image: url('#{$themePath}/icon/settings/download.svg'); }
}

.pageSettingsSpaceShare {
Expand Down
40 changes: 37 additions & 3 deletions src/ts/component/page/main/settings/data/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { forwardRef } from 'react';
import { Title, Label, Button, Icon } from 'Component';
import React, { forwardRef, useState, useEffect } from 'react';
import { Title, Label, Button, Icon, Switch } from 'Component';
import { I, C, S, U, translate, analytics, Action } from 'Lib';
import { observer } from 'mobx-react';

const PageMainSettingsDataIndex = observer(forwardRef<I.PageRef, I.PageSettingsComponent>((props, ref) => {

const [ autodownload, setAutodownload ] = useState(true);
const { dataPath, spaceStorage } = S.Common;
const { localUsage } = spaceStorage;
const isLocalNetwork = U.Data.isLocalNetwork();
Expand Down Expand Up @@ -47,6 +48,22 @@ const PageMainSettingsDataIndex = observer(forwardRef<I.PageRef, I.PageSettingsC
analytics.event('ClickSettingsDataManagementLocation', { route: analytics.route.settings });
};

const getAutodownloadStatus = () => {
// TODO: finish when MW is ready
};

const onAutoDownloadSwitch = (e: any, v: boolean) => {
C.FileSetAutoDownload(v, (message) => {
if (!message.error) {
setAutodownload(v);
};
});
};

useEffect(() => {
getAutodownloadStatus();
}, []);

return (
<>
<Title text={translate('popupSettingsLocalStorageTitle')} />
Expand Down Expand Up @@ -81,10 +98,27 @@ const PageMainSettingsDataIndex = observer(forwardRef<I.PageRef, I.PageSettingsC
<Button color="blank" className="c28" text={translate(`commonOpen`)} onClick={onOpenDataLocation} />
</div>
</div>

<div className="item">
<div className="side left">
<Icon className="download" />

<div className="txt">
<div className="name">{translate('popupSettingsDataOfflineAccess')}</div>
<div className="type">{translate(`popupSettingsDataOfflineAccessDescription`)}</div>
</div>
</div>
<div className="side right">
<Switch
value={autodownload}
onChange={onAutoDownloadSwitch}
/>
</div>
</div>
</div>
</>
);

}));

export default PageMainSettingsDataIndex;
export default PageMainSettingsDataIndex;
10 changes: 9 additions & 1 deletion src/ts/lib/api/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,14 @@ export const FileDiscardPreload = (fileId: string, callBack?: (message: any) =>
dispatcher.request(FileDiscardPreload.name, request, callBack);
};

export const FileSetAutoDownload = (enabled: boolean, callBack?: (message: any) => void) => {
const request = new Rpc.File.SetAutoDownload.Request();

request.setEnabled(enabled);

dispatcher.request(FileSetAutoDownload.name, request, callBack);
};

// ---------------------- NAVIGATION ---------------------- //

export const NavigationGetObjectInfoWithLinks = (pageId: string, callBack?: (message: any) => void) => {
Expand Down Expand Up @@ -2535,4 +2543,4 @@ export const PushNotificationAddAllIds = (spaceId: string, ids: string[], callBa
request.setChatidsList(ids);

dispatcher.request(PushNotificationAddAllIds.name, request, callBack);
};
};