Skip to content

fix dirtyAttributes to look at persisted values rather than latest and remove observability from data property on store#459

Open
jondayton wants to merge 2 commits intomainfrom
fix-saving
Open

fix dirtyAttributes to look at persisted values rather than latest and remove observability from data property on store#459
jondayton wants to merge 2 commits intomainfrom
fix-saving

Conversation

@jondayton
Copy link
Contributor

No description provided.


todo.notes.add(note)
note.description = 'something different'
todo.notes.replace([note, note2])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this takes a snapshot, which was making dirtyAttributes compare against the latest version of the model instead of the original one.

Comment on lines +682 to +684
records: new Map(),
cache: new Map(),
meta: new Map()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're not actually observing this anywhere, so it's just a performance hit. It would be cool to observe it though.

return Object.keys(this.attributes).reduce((dirtyAccumulator, attr) => {
const currentValue = this.attributes[attr]
const previousValue = this.previousSnapshot.attributes[attr]
const previousValue = this.persistedOrFirstSnapshot.attributes[attr]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's the fix

Comment on lines +299 to +303
expect(store.data).toEqual({
todos: { cache: new Map(), meta: new Map(), records: new Map() },
notes: { cache: new Map(), meta: new Map(), records: new Map() },
categories: { cache: new Map(), meta: new Map(), records: new Map() },
tags: { cache: new Map(), meta: new Map(), records: new Map() }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fora performance improvement (see below)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants