Skip to content

Commit

Permalink
[desk-tool] Add currentObjectDiff()
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr authored and rexxars committed Oct 6, 2020
1 parent 66ec55f commit c4d247f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {SanityClient} from '@sanity/client'
import {Observable} from 'rxjs'
import {remoteSnapshots} from '@sanity/base/lib/datastores/document/document-pair/remoteSnapshots'
import {ObjectDiff} from '@sanity/diff'
import {Timeline, ParsedTimeRef} from './timeline'
import {getJsonStream} from './ndjsonStreamer'
import {RemoteSnapshotVersionEvent, Chunk} from './types'
Expand Down Expand Up @@ -197,6 +198,12 @@ export class Controller {
return this._reconstruction ? this._reconstruction.diff() : null
}

currentObjectDiff(): ObjectDiff<any> | null {
const diff = this.currentDiff()
if (diff && diff.type !== 'object') throw new Error(`ObjectDiff expected, got ${diff.type}`)
return diff
}

handleRemoteMutation(ev: RemoteSnapshotVersionEvent) {
this._aligner.appendRemoteSnapshotEvent(ev)
this.markChange()
Expand Down

0 comments on commit c4d247f

Please sign in to comment.