Sync on ctrl+s (#1770)

This commit is contained in:
Compositr
2023-10-11 06:19:23 +11:00
committed by GitHub
parent 3dfe633428
commit bdf5c45cda
2 changed files with 41 additions and 24 deletions

View File

@@ -32,6 +32,7 @@ import Link from './common/Link';
import Paragraph from './common/Paragraph';
import Text from './common/Text';
import View from './common/View';
import { KeyHandlers } from './KeyHandlers';
import LoggedInUser from './LoggedInUser';
import { useServerURL } from './ServerContext';
import { useSidebar } from './sidebar';
@@ -173,30 +174,40 @@ export function SyncButton({ style, isMobile = false }: SyncButtonProps) {
: {};
return (
<Button
type="bare"
style={{
...style,
WebkitAppRegion: 'none',
color: isMobile ? mobileColor : desktopColor,
}}
hoveredStyle={activeStyle}
activeStyle={activeStyle}
onClick={sync}
>
{syncState === 'error' ? (
<AlertTriangle width={13} />
) : (
<AnimatedRefresh animating={syncing} />
)}
<Text style={{ marginLeft: 3 }}>
{syncState === 'disabled'
? 'Disabled'
: syncState === 'offline'
? 'Offline'
: 'Sync'}
</Text>
</Button>
<>
<KeyHandlers
keys={{
'ctrl+s, cmd+s': () => {
sync();
},
}}
/>
<Button
type="bare"
style={{
...style,
WebkitAppRegion: 'none',
color: isMobile ? mobileColor : desktopColor,
}}
hoveredStyle={activeStyle}
activeStyle={activeStyle}
onClick={sync}
>
{syncState === 'error' ? (
<AlertTriangle width={13} />
) : (
<AnimatedRefresh animating={syncing} />
)}
<Text style={{ marginLeft: 3 }}>
{syncState === 'disabled'
? 'Disabled'
: syncState === 'offline'
? 'Offline'
: 'Sync'}
</Text>
</Button>
</>
);
}

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [Compositr, shaankhosla]
---
Sync on Ctrl+S