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

Group gets fully replaced when sync is used and group previously failed to load #59

Open
StephanBijzitter opened this issue Nov 16, 2024 · 1 comment · May be fixed by #60
Open

Group gets fully replaced when sync is used and group previously failed to load #59

StephanBijzitter opened this issue Nov 16, 2024 · 1 comment · May be fixed by #60

Comments

@StephanBijzitter
Copy link
Contributor

image

When everything goes correctly:

  • If option 1 is used, the group on wom will match whatever is currently in the clan list
  • If option 2 is used, any users in the clan list not yet in the group are added to the group and any users in the clan list with a different rank/role have their rank/role updated on wom

However, the code for option 2 relies on the plugin having an up-to-date copy of the group as represented on wom; if this copy is not up-to-date or is missing (due to any kind of connectivity issue), option 2 becomes functionally identical to option 1.

The following code is responsible for this unexpected behaviour:

if (!overwrite)
{
groupMembers.forEach((k, v) -> clanMembers.put(k, new Member(v.getPlayer().getDisplayName(), v.getRole())));
}

A simple workaround would be to check the size of groupMembers, if this is 0 then that can mean two things:

  • either there was an issue downloading a copy, in which case it would be better to abort than to proceed
  • or the group actually has 0 members, in which case option 1 would be semantically more accurate to be used anyway
@StephanBijzitter
Copy link
Contributor Author

Ideally though the endpoint used should be changed to use the POST variant (assuming that adding an existing member with a different rank, will update that member's rank): https://docs.wiseoldman.net/groups-api/group-endpoints#add-members

StephanBijzitter added a commit to StephanBijzitter/wiseoldman-runelite-plugin that referenced this issue Nov 16, 2024
Fixes wise-old-man#59 by re-downloading all group members and waiting for `plugin.groupMembers` to be updated
before automatically re-running this function with the up-to-date information.

It works, but could use some love.
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 a pull request may close this issue.

1 participant