Skip to content
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

Desktop,Mobile: Sync: Fix share not marked as readonly if the recipient has an outgoing share #11770

Merged

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Feb 3, 2025

Summary

Suppose user A has an outgoing share, but then accepts an incoming read-only share from user B. Prior to this pull request, the share from user B would be marked as writable by Joplin clients. However, all changes user A makes to the share from user B will result in conflicts (because the share is actually read-only).

This pull request updates the read-only logic to handle the case where a recipient of a share is the owner of a different share.

Testing plan

  1. Start a Joplin client that previously incorrectly marked a share as read-write.
  2. Open the previously-problematic share.
  3. Observe that the notes in the share are marked as read-only.

…s an outgoing share

The client would allow the user to write to the share, which would then
result in conflicts on sync
@personalizedrefrigerator personalizedrefrigerator added the sync sync related issue label Feb 3, 2025
Comment on lines -95 to +96
if (shareState.shares.find(s => s.user.id === userId)) return false;
const parentShare = shareState.shares.find(s => s.id === item.share_id);
if (parentShare && parentShare.user?.id === userId) return false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously,

if (shareState.shares.find(s => s.user.id === userId)) return false;

would always return if userId was the owner of a share, regardless of whether the share is the parent of the item under consideration.

@laurent22 laurent22 merged commit a16a66c into laurent22:dev Feb 6, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sync sync related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants