mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-09 19:45:17 +02:00
feat(google-docs): overwrite-confirm on sync conflict and last-synced indicator
This commit is contained in:
parent
7e6ee040aa
commit
ccdfc0f6e9
2 changed files with 23 additions and 1 deletions
|
|
@ -1454,7 +1454,19 @@ function App() {
|
|||
setGoogleDocSyncDirection('up')
|
||||
markRecentLocalMarkdownWrite(path)
|
||||
try {
|
||||
const result = await window.ipc.invoke('google-docs:sync', { path, markdown })
|
||||
let result = await window.ipc.invoke('google-docs:sync', { path, markdown })
|
||||
if (result.conflict) {
|
||||
const overwrite = window.confirm(
|
||||
'This Google Doc changed since your last sync.\n\n' +
|
||||
'Overwrite it with your local version? Cancel to keep the remote copy ' +
|
||||
'(use “Sync down” to pull it first).',
|
||||
)
|
||||
if (!overwrite) {
|
||||
toast.info('Sync up cancelled — remote Google Doc is unchanged')
|
||||
return
|
||||
}
|
||||
result = await window.ipc.invoke('google-docs:sync', { path, markdown, force: true })
|
||||
}
|
||||
if (!result.synced) {
|
||||
throw new Error(result.error || 'This note is not linked to a Google Doc.')
|
||||
}
|
||||
|
|
@ -5776,6 +5788,7 @@ function App() {
|
|||
googleDoc={linkedGoogleDoc && !isViewingHistory ? {
|
||||
title: linkedGoogleDoc.title,
|
||||
isSyncing: isActive ? googleDocSyncDirection : null,
|
||||
lastSyncedAt: linkedGoogleDoc.syncedAt,
|
||||
onOpen: () => {
|
||||
if (linkedGoogleDoc.url) {
|
||||
window.open(linkedGoogleDoc.url, '_blank')
|
||||
|
|
|
|||
|
|
@ -39,9 +39,11 @@ import {
|
|||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import { formatRelativeTime } from '@/lib/relative-time'
|
||||
|
||||
interface EditorToolbarProps {
|
||||
editor: Editor | null
|
||||
|
|
@ -56,6 +58,7 @@ interface EditorToolbarProps {
|
|||
export interface GoogleDocToolbarState {
|
||||
title: string
|
||||
isSyncing?: 'up' | 'down' | null
|
||||
lastSyncedAt?: string
|
||||
onOpen: () => void
|
||||
onSyncDown: () => void
|
||||
onSyncUp: () => void
|
||||
|
|
@ -470,6 +473,12 @@ export function EditorToolbar({
|
|||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuLabel className="font-normal text-muted-foreground">
|
||||
{googleDoc.lastSyncedAt
|
||||
? `Last synced ${formatRelativeTime(googleDoc.lastSyncedAt)}`
|
||||
: 'Not synced yet'}
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onClick={googleDoc.onOpen}>
|
||||
<GoogleDriveIcon className="size-4 mr-2" />
|
||||
Open Google Doc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue