-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update publish logic with edge case #4580
Update publish logic with edge case #4580
Conversation
return db | ||
.table(TABLE_NAMES.CONTENTNODE) | ||
.where({ channel_id: change.channel_id }) | ||
.and(node => { | ||
const unpublishedNodeIds = db[TABLE_NAMES.CHANGES_TABLE] | ||
.where({ table: TABLE_NAMES.CONTENTNODE }) |
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.
It didn't occur to me before, but couldn't we just add an additional where
condition here so this becomes:
.where({ table: TABLE_NAMES.CONTENTNODE, key: node.id })
.limit(1)
.toArray();
return unpublishedNodeIds.length === 0;
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.
Oh yeah more cleaner!
.limit(1) | ||
.toArray(); | ||
return unpublishedNodeIds.length === 0; | ||
}) |
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.
@rtibbles, we should be good now, I think?
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 think so!
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.
Code looks good, will do a quick manual test locally to confirm.
.limit(1) | ||
.toArray(); | ||
return unpublishedNodeIds.length === 0; | ||
}) |
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 think so!
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 manual test checks out, this is good to go! Beautiful stuff.
Summary
Description of the change(s) you made
This PR enhances the remote publish logic to safeguard against accidental overwrites of the
changes
andpublished
statuses in IndexedDB, particularly in scenarios where multiple users are editing the same resource. It ensures that one user's publish action does not inadvertently overwrite another user's unpublished changes.Manual verification steps performed
CONTENTNODE
andCHANGES_TABLE
in IndexedDB to verify that the syncing has no effect on changes.Does this introduce any tech-debt items?
Reviewer guidance
How can a reviewer test these changes?
References
Fixes #4138
Comments
Contributor's Checklist
PR process:
CHANGELOG
label been added to this PR. Note: items with this label will be added to the CHANGELOG at a later timedocs
label has been added if this introduces a change that needs to be updated in the user docs?requirements.txt
files also included in this PRStudio-specifc:
notranslate
class been added to elements that shouldn't be translated by Google Chrome's automatic translation feature (e.g. icons, user-generated text)pages
,components
, andlayouts
directories as described in the docsTesting:
Reviewer's Checklist
This section is for reviewers to fill out.
yarn
andpip
)