diff --git a/app/scenes/Document/components/MultiplayerEditor.tsx b/app/scenes/Document/components/MultiplayerEditor.tsx index d37ad3ce8..aa7dff622 100644 --- a/app/scenes/Document/components/MultiplayerEditor.tsx +++ b/app/scenes/Document/components/MultiplayerEditor.tsx @@ -36,7 +36,10 @@ type AwarenessChangeEvent = { type ConnectionStatusEvent = { status: ConnectionStatus }; -type MessageEvent = { message: string }; +type MessageEvent = { + message: string; + event: Event; +}; function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) { const documentId = props.id; @@ -138,6 +141,17 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) { setRemoteSynced(true); }); + provider.on("close", (ev: MessageEvent) => { + if ("code" in ev.event && ev.event.code === 1009) { + provider.shouldConnect = false; + showToast( + t( + "Sorry, this document is too large - edits will no longer be persisted." + ) + ); + } + }); + if (debug) { provider.on("close", (ev: MessageEvent) => Logger.debug("collaboration", "close", ev) diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 3f3c58e8a..2f9e88e9c 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -492,6 +492,7 @@ "Viewed {{ count }} times by {{ teamMembers }} people": "Viewed {{ count }} time by {{ teamMembers }} people", "Viewed {{ count }} times by {{ teamMembers }} people_plural": "Viewed {{ count }} times by {{ teamMembers }} people", "Sorry, it looks like you don’t have permission to access the document": "Sorry, it looks like you don’t have permission to access the document", + "Sorry, this document is too large - edits will no longer be persisted.": "Sorry, this document is too large - edits will no longer be persisted.", "Sorry, the last change could not be persisted – please reload the page": "Sorry, the last change could not be persisted – please reload the page", "This template will be permanently deleted in <2> unless restored.": "This template will be permanently deleted in <2> unless restored.", "This document will be permanently deleted in <2> unless restored.": "This document will be permanently deleted in <2> unless restored.",