Skip to content

Commit

Permalink
#1503 dupicates on upsync: prevent user assignment duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
desperateCoder committed Nov 17, 2024
1 parent ff49d3c commit 31ca9ec
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class CardDataProvider extends AbstractSyncDataProvider<FullCard> {
private static final String ALREADY_ARCHIVED_INDICATOR = "Operation not allowed. This card is archived.";
// see https://github.com/stefan-niedermann/nextcloud-deck/issues/1073
private static final Set<JoinCardWithLabel> LABEL_JOINS_IN_SYNC = Collections.synchronizedSet(new HashSet<>());
private static final Set<JoinCardWithUser> USER_JOINS_IN_SYNC = Collections.synchronizedSet(new HashSet<>());
protected Board board;
protected FullStack stack;

Expand Down Expand Up @@ -345,12 +346,22 @@ public void onResponse(EmptyResponse response, Headers headers) {
}
});
} else if (changedUser.getStatusEnum() == DBStatus.LOCAL_EDITED) {
serverAdapter.assignUserToCard(board.getId(), stack.getId(), changedUser.getCardId(), user.getUid(), new ResponseCallback<>(account) {
@Override
public void onResponse(EmptyResponse response, Headers headers) {
dataBaseAdapter.setStatusForJoinCardWithUser(card.getLocalId(), user.getLocalId(), DBStatus.UP_TO_DATE.getId());
}
});
if (!USER_JOINS_IN_SYNC.contains(changedUser)) {
USER_JOINS_IN_SYNC.add(changedUser);
serverAdapter.assignUserToCard(board.getId(), stack.getId(), changedUser.getCardId(), user.getUid(), new ResponseCallback<>(account) {
@Override
public void onResponse(EmptyResponse response, Headers headers) {
dataBaseAdapter.setStatusForJoinCardWithUser(card.getLocalId(), user.getLocalId(), DBStatus.UP_TO_DATE.getId());
USER_JOINS_IN_SYNC.remove(changedUser);
}

@Override
public void onError(Throwable throwable) {
super.onError(throwable);
USER_JOINS_IN_SYNC.remove(changedUser);
}
});
}
}
}

Expand Down

0 comments on commit 31ca9ec

Please sign in to comment.