Skip to content
Open
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
11 changes: 11 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ export default defineComponent({

onSave() {
if (this.fileNode) {
// Cheap file update for Files app while the editor is still open
this.fileNode.mtime = new Date()
this.fileNode.size = new Blob([this.serialize()]).size
emit('files:node:updated', this.fileNode)
Expand Down Expand Up @@ -728,6 +729,16 @@ export default defineComponent({
logger.warn('Failed to destroy editor', { error })
}
}

// Update the file in Files with the latest size, mtime, the lock state
if (this.fileNode) {
const updatedNode = await fetchNode(this.fileNode).catch((err) =>
logger.warn('Failed to fetch node', { err }),
)
if (updatedNode) {
emit('files:node:updated', updatedNode)
}
}
},

/**
Expand Down
14 changes: 9 additions & 5 deletions src/services/SyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,20 @@ class SyncService {

async close() {
this.backend?.disconnect()
if (this.hasActiveConnection()) {
close(this.connection.value)

const activeConnection = this.connection.value

// Clear connection immediately so hasActiveConnection turns false and we can reconnect.
this.connection.value = undefined
this.bus.emit('close')

if (activeConnection) {
await close(activeConnection)
// Log and ignore possible network issues.
.catch((e) => {
logger.info('Failed to close connection.', { e })
})
}
// Clear connection so hasActiveConnection turns false and we can reconnect.
this.connection.value = undefined
this.bus.emit('close')
}
}

Expand Down
Loading