Skip to content

Commit

Permalink
consistent use of encodeHeads
Browse files Browse the repository at this point in the history
  • Loading branch information
pvh committed Jan 17, 2025
1 parent 4ebcdf9 commit 8dd6512
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/automerge-repo/src/DocHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ export class DocHandle<T> extends EventEmitter<DocHandleEvents<T>> {
#checkForChanges(before: A.Doc<T>, after: A.Doc<T>) {
const beforeHeads = A.getHeads(before)
const afterHeads = A.getHeads(after)
const docChanged = !headsAreSame(afterHeads, beforeHeads)
const docChanged = !headsAreSame(
encodeHeads(afterHeads),
encodeHeads(beforeHeads)
)
if (docChanged) {
this.emit("heads-changed", { handle: this, doc: after })

Expand Down
3 changes: 2 additions & 1 deletion packages/automerge-repo/src/storage/StorageSubsystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { keyHash, headsHash } from "./keyHash.js"
import { chunkTypeFromKey } from "./chunkTypeFromKey.js"
import * as Uuid from "uuid"
import { EventEmitter } from "eventemitter3"
import { encodeHeads } from "../AutomergeUrl.js"

type StorageSubsystemEvents = {
"document-loaded": (arg: {
Expand Down Expand Up @@ -280,7 +281,7 @@ export class StorageSubsystem extends EventEmitter<StorageSubsystemEvents> {
}

const newHeads = A.getHeads(doc)
if (headsAreSame(newHeads, oldHeads)) {
if (headsAreSame(encodeHeads(newHeads), encodeHeads(oldHeads))) {
// the document hasn't changed
return false
}
Expand Down

0 comments on commit 8dd6512

Please sign in to comment.