mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
[ide-react] Address some migration TODOs (#16033)
* Add type for externalUpdate * Log clientTracking.getConnectedUsers error * Remove update debugging code * Use ErrorMetadata type * Use Message type * Remove unused document:opened event GitOrigin-RevId: 3a1d1e785dca37d6b91cd650fbcb4e5decb6343b
This commit is contained in:
@@ -37,7 +37,24 @@ const MAX_PENDING_OP_SIZE = 64
|
||||
type JoinCallback = (error?: Error) => void
|
||||
type LeaveCallback = JoinCallback
|
||||
|
||||
type Update = Record<string, any>
|
||||
type Update =
|
||||
| {
|
||||
v: number
|
||||
doc: string
|
||||
}
|
||||
| {
|
||||
v: number
|
||||
doc: string
|
||||
op: AnyOperation[]
|
||||
meta: {
|
||||
type?: string
|
||||
source: string
|
||||
user_id: string
|
||||
ts: number
|
||||
}
|
||||
hash?: string
|
||||
lastV?: number
|
||||
}
|
||||
|
||||
type Message = {
|
||||
meta: {
|
||||
@@ -101,9 +118,6 @@ export class Document extends EventEmitter {
|
||||
if (this.cm6) {
|
||||
this.cm6.on('change', this.checkConsistency)
|
||||
}
|
||||
if (this.doc) {
|
||||
this.ideEventEmitter.emit('document:opened', this.doc)
|
||||
}
|
||||
}
|
||||
|
||||
detachFromCM6() {
|
||||
@@ -183,8 +197,7 @@ export class Document extends EventEmitter {
|
||||
|
||||
private onUpdateAppliedHandler = (update: any) => this.onUpdateApplied(update)
|
||||
|
||||
// TODO: MIGRATION: Create proper types for error and message
|
||||
private onErrorHandler = (error: Error, message: { doc_id: string }) => {
|
||||
private onErrorHandler = (error: Error, message: ErrorMetadata) => {
|
||||
// 'otUpdateError' are emitted per doc socket.io room, hence we can be
|
||||
// sure that message.doc_id exists.
|
||||
if (message.doc_id !== this.doc_id) {
|
||||
|
||||
@@ -65,20 +65,6 @@ export class ShareJsDoc extends EventEmitter {
|
||||
this.connection = {
|
||||
send: (update: Update) => {
|
||||
this.startInflightOpTimeout(update)
|
||||
// TODO: MIGRATION: Work out whether we can get rid of this. It looks as
|
||||
// though it's here for debugging and isn't used
|
||||
|
||||
// if (
|
||||
// window.disconnectOnUpdate != null &&
|
||||
// Math.random() < window.disconnectOnUpdate
|
||||
// ) {
|
||||
// debugConsole.log('Disconnecting on update', update)
|
||||
// this.socket.disconnect()
|
||||
// }
|
||||
// if (window.dropUpdates != null && Math.random() < window.dropUpdates) {
|
||||
// debugConsole.log('Simulating a lost update', update)
|
||||
// return
|
||||
// }
|
||||
if (this.track_changes && this.track_changes_id_seeds) {
|
||||
if (update.meta == null) {
|
||||
update.meta = {}
|
||||
|
||||
@@ -8,14 +8,13 @@ export type ShareJsOperation = AnyOperation[]
|
||||
|
||||
export type TrackChangesIdSeeds = { inflight: string; pending: string }
|
||||
|
||||
export type Message = Record<string, any>
|
||||
// TODO: MIGRATION: Make an accurate and more specific type
|
||||
// {
|
||||
// v: Version
|
||||
// open?: boolean
|
||||
// meta?: {
|
||||
// type: string
|
||||
// }
|
||||
// doc?: string
|
||||
// snapshot?: string
|
||||
// }
|
||||
// TODO: check the properties of this type
|
||||
export type Message = {
|
||||
v: Version
|
||||
open?: boolean
|
||||
meta?: {
|
||||
type?: string
|
||||
}
|
||||
doc?: string
|
||||
snapshot?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user