-
Notifications
You must be signed in to change notification settings - Fork 27
MLIBZ-2131 Remove implicit push() calls #276
Conversation
3239322
to
27135dc
Compare
src/core/datastore/utils/utils.js
Outdated
import { isNonemptyString } from '../../utils'; | ||
|
||
export const dataStoreTagSeparator = '.'; | ||
|
||
export function getEntitiesPendingPushError(entityCount, prefix) { | ||
const countMsg = `There are ${entityCount} entities, matching this query or id, pending push to the backend.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use an if
statement to make the count message more grammatically correct.
let countMsg = `There are ${entityCount} entities, matching the provided query, pending push to the backend.`;
if (entityCount === 1) {
countMsg = `There is ${entitiyCount} entity, matching the provided query or id, pending push to the backend.`;
}
src/core/datastore/utils/utils.js
Outdated
import { isNonemptyString } from '../../utils'; | ||
|
||
export const dataStoreTagSeparator = '.'; | ||
|
||
export function getEntitiesPendingPushError(entityCount, prefix) { | ||
const countMsg = `There are ${entityCount} entities, matching this query or id, pending push to the backend.`; | ||
const errMsg = `Unable to ${prefix} on the backend, since the result might overwrite your local changes. ${countMsg}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to break up the error message into two sentences.
const errMsg = `Unable to ${prefix} on the backend. The result might overwrite your local changes.`;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused. When does errMsg
get used?
I think the revised version from Thomas is an improvement, but I'd like to avoid the phrase "might overwrite" if possible. Can we say something more concrete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errMsg
is the entire message - it's always used. Just there were a few, slightly different, error messages (thus "prefix" parameter).
The method exists just to build the error message. As we discussed, there will someday be a general error factory, but until then, this will have to suffice.
I guess "the returned entities would overwrite your local entities" is more concrete. How about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result will overwrite your local changes.
@tejasranade thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I think will
or can
sounds more concrete. @thomasconner let's go with yours.
…Store. Remove outdated tests, change error message for when entities are pending push. Change tests to feature the new message.
…Update tests accordingly.
…re.count(), that returned an error when there are entities to push. Change tests accordingly.
27135dc
to
26f9e86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Remove the implicit push() calls in DataStore.pull(), CacheStore.find(), CacheStore.findById(), CacheStore.count(), CacheStore.group(). This removes potentially unexpected behaviour and improves the number of local reads from 2 to 4, to always 2.
Changes
Remove the count-push-count flow from CacheStore read-based ops. They do count and return an error if there are entities pending push. Otherwise proceed with their regular flow.
Put the check for entities pending push after the return of the offline result - it isn't being impeded by the entities pending sync.
Update tests accordingly.
Change the error message - input welcome.