Accomodate membership id (#6221)
* fix: accomodate membership id * fix: remove only * fix: event handling * fix: tests * fix: use transaction * Remove useless test --------- Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
@@ -71,13 +71,18 @@ export default class CollectionGroupMembershipsStore extends Store<CollectionGro
|
||||
id: collectionId,
|
||||
groupId,
|
||||
});
|
||||
this.remove(`${groupId}-${collectionId}`);
|
||||
const membership = Array.from(this.data.values()).find(
|
||||
(m) => m.groupId === groupId && m.collectionId === collectionId
|
||||
);
|
||||
if (membership) {
|
||||
this.remove(membership.id);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
removeCollectionMemberships = (collectionId: string) => {
|
||||
this.data.forEach((membership, key) => {
|
||||
if (key.includes(collectionId)) {
|
||||
if (membership.collectionId === collectionId) {
|
||||
this.remove(key);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -71,16 +71,31 @@ export default class MembershipsStore extends Store<Membership> {
|
||||
id: collectionId,
|
||||
userId,
|
||||
});
|
||||
this.remove(`${userId}-${collectionId}`);
|
||||
this.rootStore.users.remove(userId);
|
||||
this.revoke({ userId, collectionId });
|
||||
}
|
||||
|
||||
@action
|
||||
removeCollectionMemberships = (collectionId: string) => {
|
||||
this.data.forEach((membership, key) => {
|
||||
if (key.includes(collectionId)) {
|
||||
if (membership.collectionId === collectionId) {
|
||||
this.remove(key);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@action
|
||||
revoke = ({
|
||||
userId,
|
||||
collectionId,
|
||||
}: {
|
||||
collectionId: string;
|
||||
userId: string;
|
||||
}) => {
|
||||
const membership = Array.from(this.data.values()).find(
|
||||
(m) => m.userId === userId && m.collectionId === collectionId
|
||||
);
|
||||
if (membership) {
|
||||
this.remove(membership.id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user