forked from standardnotes/app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "sync" pane to preferences -> account tab (standardnotes#621)
* feat: add "sync" pane to preferences -> account tab * chore: configure eslint to add new line at the end of file and remove trailing spaces * chore: add newline at the end of file
- Loading branch information
1 parent
41e1dd9
commit 5b18fc7
Showing
11 changed files
with
121 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
# OS & IDE | ||
.DS_Store | ||
.idea | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/assets/javascripts/preferences/panes/AccountPreferences.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Sync } from '@/preferences/panes/account'; | ||
import { PreferencesPane } from '@/preferences/components'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { WebApplication } from '@/ui_models/application'; | ||
|
||
export const AccountPreferences = observer(({application}: {application: WebApplication}) => { | ||
return ( | ||
<PreferencesPane> | ||
<Sync application={application} /> | ||
</PreferencesPane> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { PreferencesGroup, PreferencesSegment, Text, Title } from '@/preferences/components'; | ||
import { Button } from '@/components/Button'; | ||
import { SyncQueueStrategy } from '@node_modules/@standardnotes/snjs'; | ||
import { STRING_GENERIC_SYNC_ERROR } from '@/strings'; | ||
import { useState } from '@node_modules/preact/hooks'; | ||
import { dateToLocalizedString } from '@/utils'; | ||
import { observer } from '@node_modules/mobx-react-lite'; | ||
import { WebApplication } from '@/ui_models/application'; | ||
|
||
type Props = { | ||
application: WebApplication; | ||
}; | ||
|
||
const Sync = observer(({ application }: Props) => { | ||
const formatLastSyncDate = (lastUpdatedDate: Date) => { | ||
return dateToLocalizedString(lastUpdatedDate); | ||
}; | ||
|
||
const [isSyncingInProgress, setIsSyncingInProgress] = useState(false); | ||
const [lastSyncDate, setLastSyncDate] = useState(formatLastSyncDate(application.getLastSyncDate() as Date)); | ||
|
||
const doSynchronization = async () => { | ||
setIsSyncingInProgress(true); | ||
|
||
const response = await application.sync({ | ||
queueStrategy: SyncQueueStrategy.ForceSpawnNew, | ||
checkIntegrity: true | ||
}); | ||
setIsSyncingInProgress(false); | ||
if (response && response.error) { | ||
application.alertService!.alert(STRING_GENERIC_SYNC_ERROR); | ||
} else { | ||
setLastSyncDate(formatLastSyncDate(application.getLastSyncDate() as Date)); | ||
} | ||
}; | ||
|
||
return ( | ||
<PreferencesGroup> | ||
<PreferencesSegment> | ||
<div className='flex flex-row items-center'> | ||
<div className='flex-grow flex flex-col'> | ||
<Title>Sync</Title> | ||
<Text> | ||
Last synced <span className='font-bold'>on {lastSyncDate}</span> | ||
</Text> | ||
<Button | ||
className='min-w-20 mt-3' | ||
type='normal' | ||
label='Sync now' | ||
disabled={isSyncingInProgress} | ||
onClick={doSynchronization} | ||
/> | ||
</div> | ||
</div> | ||
</PreferencesSegment> | ||
</PreferencesGroup> | ||
); | ||
}); | ||
|
||
export default Sync; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Sync } from './Sync'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './HelpFeedback'; | ||
export * from './Security'; | ||
export * from './AccountPreferences'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2016,6 +2016,11 @@ | |
resolved "https://registry.yarnpkg.com/@standardnotes/auth/-/auth-3.1.1.tgz#834701c2e14d31eb204bff90457fa05e9183464a" | ||
integrity sha512-E9zDYZ1gJkVZBEzd7a1L2haQ4GYeH1lUrY87UmDH1AMYUHW+c0SqZ71af1fBNqGzrx3EZSXk+Qzr7RyOa6N1Mw== | ||
|
||
"@standardnotes/[email protected]": | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.0.0.tgz#906af029b6e58241689ca37436982c37a888a418" | ||
integrity sha512-PEQyP/p/TQLVcNYcbu9jEIWNRqBrFFG1Qyy8QIcvNUt5o4lpLZGEY1T+PJUsPSisnuKKNpQrgVLc9LjhUKpuYw== | ||
|
||
"@standardnotes/sncrypto-common@^1.2.7", "@standardnotes/sncrypto-common@^1.2.9": | ||
version "1.2.9" | ||
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.2.9.tgz#5212a959e4ec563584e42480bfd39ef129c3cbdf" | ||
|
@@ -2029,12 +2034,13 @@ | |
"@standardnotes/sncrypto-common" "^1.2.7" | ||
libsodium-wrappers "^0.7.8" | ||
|
||
"@standardnotes/[email protected].21": | ||
version "2.7.21" | ||
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.21.tgz#db451e5facaf5fa41fa509eb1f304723929c3541" | ||
integrity sha512-GhkGk1LJmD494COZkSOgyHaUnGnLWNLlSuCZMTwbw3dgkN5PjobbRhfDvEZaLqjwok+h9nkiQt3hugQ3h6Cy5w== | ||
"@standardnotes/[email protected].23": | ||
version "2.7.23" | ||
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.23.tgz#fedc9c025301dbe20ed2d598fb378e36f90ff64e" | ||
integrity sha512-eoEwKlV2PZcJXFbCt6bgovu9nldVoT7DPoterTBo/NZ4odRILOwxLA1SAgL5H5FYPb9NHkwaaCt9uTdIqdNYhA== | ||
dependencies: | ||
"@standardnotes/auth" "3.1.1" | ||
"@standardnotes/features" "1.0.0" | ||
"@standardnotes/sncrypto-common" "^1.2.9" | ||
|
||
"@svgr/babel-plugin-add-jsx-attribute@^5.4.0": | ||
|