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
|
isNc
|
||||||
name
|
name
|
||||||
thumbnailUrl
|
thumbnailUrl
|
||||||
|
currentUserWantsThis
|
||||||
allOccupiedZones {
|
allOccupiedZones {
|
||||||
id
|
id
|
||||||
label @client
|
label @client
|
||||||
|
@ -48,22 +49,13 @@ function UserItemsPage() {
|
||||||
isNc
|
isNc
|
||||||
name
|
name
|
||||||
thumbnailUrl
|
thumbnailUrl
|
||||||
|
currentUserOwnsThis
|
||||||
allOccupiedZones {
|
allOccupiedZones {
|
||||||
id
|
id
|
||||||
label @client
|
label @client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentUser {
|
|
||||||
itemsTheyOwn {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
|
|
||||||
itemsTheyWant {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ variables: { userId } }
|
{ variables: { userId } }
|
||||||
|
@ -81,20 +73,13 @@ function UserItemsPage() {
|
||||||
return <Box color="red.400">{error.message}</Box>;
|
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
|
// 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 want it, we say "You want this!". And if they want
|
||||||
// something, and you own it, we say "You own this!".
|
// something, and you own it, we say "You own this!".
|
||||||
const showYouOwnThisBadge = (item) =>
|
const showYouOwnThisBadge = (item) =>
|
||||||
!isCurrentUser && itemIdsYouOwn.has(item.id);
|
!isCurrentUser && item.currentUserOwnsThis;
|
||||||
const showYouWantThisBadge = (item) =>
|
const showYouWantThisBadge = (item) =>
|
||||||
!isCurrentUser && itemIdsYouWant.has(item.id);
|
!isCurrentUser && item.currentUserWantsThis;
|
||||||
|
|
||||||
const numYouOwnThisBadges = data.user.itemsTheyWant.filter(
|
const numYouOwnThisBadges = data.user.itemsTheyWant.filter(
|
||||||
showYouOwnThisBadge
|
showYouOwnThisBadge
|
||||||
|
|
Loading…
Reference in a new issue