update trade list matching after changing own/want
That is, if you're browsing a trade list and you go "oh actually, I _do_ want that!", and click the item page to mark it, then click Back, we'll now update the matching stuff on the trade list page to reflect that it's now a match. This was just a matter of simplifying the GraphQL query, I think the `currentUserOwnsThis` and `currentUserWantsThis` fields just didn't exist at the time? We _don't_ yet update your _own_ trade list, if you click through to an item to remove it or something like that. The cache update function isn't too tricky, but it's a bit verbose to implement in Apollo, so I'm not bothering right now!
This commit is contained in:
parent
4d4d475437
commit
444887b64f
1 changed files with 4 additions and 19 deletions
|
@ -37,6 +37,7 @@ function UserItemsPage() {
|
|||
isNc
|
||||
name
|
||||
thumbnailUrl
|
||||
currentUserWantsThis
|
||||
allOccupiedZones {
|
||||
id
|
||||
label @client
|
||||
|
@ -48,22 +49,13 @@ function UserItemsPage() {
|
|||
isNc
|
||||
name
|
||||
thumbnailUrl
|
||||
currentUserOwnsThis
|
||||
allOccupiedZones {
|
||||
id
|
||||
label @client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentUser {
|
||||
itemsTheyOwn {
|
||||
id
|
||||
}
|
||||
|
||||
itemsTheyWant {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
{ variables: { userId } }
|
||||
|
@ -81,20 +73,13 @@ function UserItemsPage() {
|
|||
return <Box color="red.400">{error.message}</Box>;
|
||||
}
|
||||
|
||||
const itemIdsYouOwn = new Set(
|
||||
data.currentUser?.itemsTheyOwn.map((i) => i.id) || []
|
||||
);
|
||||
const itemIdsYouWant = new Set(
|
||||
data.currentUser?.itemsTheyWant.map((i) => i.id) || []
|
||||
);
|
||||
|
||||
// This helps you compare your owns/wants to other users! If they own
|
||||
// something, and you want it, we say "You want this!". And if they want
|
||||
// something, and you own it, we say "You own this!".
|
||||
const showYouOwnThisBadge = (item) =>
|
||||
!isCurrentUser && itemIdsYouOwn.has(item.id);
|
||||
!isCurrentUser && item.currentUserOwnsThis;
|
||||
const showYouWantThisBadge = (item) =>
|
||||
!isCurrentUser && itemIdsYouWant.has(item.id);
|
||||
!isCurrentUser && item.currentUserWantsThis;
|
||||
|
||||
const numYouOwnThisBadges = data.user.itemsTheyWant.filter(
|
||||
showYouOwnThisBadge
|
||||
|
|
Loading…
Reference in a new issue