Commit graph

1143 commits

Author SHA1 Message Date
2ee48250da Fix caching for search result pages
Apollo Client is pretty darn reliant on an `id` field for effective caching, more often than you'd think!

Before this change, navigating back to a page you'd already loaded would cause it to reload. After this change, it no longer does, and serves the page from cache instead!
2022-10-14 19:38:26 -07:00
a9aeab12a3 Scroll to top when item search page number changes
We also didn't need the query one, because we now `key` the `SearchResults` by the query, so the container becomes empty-then-full-again, which resets scroll back to top.
2022-10-14 19:33:45 -07:00
45b0aba736 Fix comment 2022-10-14 19:27:05 -07:00
6be5dd74d3 Homepage update: item search pagination 2022-10-14 19:21:55 -07:00
4cdfff03d1 Use pagination instead of infinite scrolling
idk this has been a long-time popular request, so I'm just gonna like. throw it all the way out there. and see what people think of it

I'm a bit worried it might change up the mobile experience too much? But like. let's find out!
2022-10-14 19:19:56 -07:00
ca58bc1be3 Refactor URL routing out of PaginationToolbar
in preparation for PaginationToolbar being able to support other kinds of state!
2022-10-14 18:27:44 -07:00
98e89e4302 Refactor router pagination into a hook
My intention is to move this out of PaginationToolbar entirely, so that it becomes a component we can reuse in a non-URL-state setting. (I'm looking at using pagination for the wardrobe item search is why!)
2022-10-14 18:01:31 -07:00
9a54694e31 Remove Metaverse license notice
It's covered in the Terms now, and I don't think they can reasonably claim they didn't know, lol
2022-10-14 17:44:26 -07:00
8b3c256a5c Time out manifest requests after 2sec
We do a thing where we sometimes proactively update an appearance layer's manifest from images.neopets.com when it's been a while since the last time, _during_ user requests.

But when images.neopets.com is being slow, this makes our API requests about appearances super slow, too!

In this change, we add a 2-second timeout to those requests. That should be plenty for when images.neopets.com is in a good mood, but also give up fast enough for the site to not feel miserable lol :p (especially when the use "Use DTI's image archive" option is on!)
2022-10-13 17:00:21 -07:00
4619e86ae0 Add "Use DTI's image archive" option
just a lil thing for people to turn on if it gets truly miserable again!!
2022-10-13 16:44:20 -07:00
5e6939309a Replace imageUrl with imageUrlV2 in-app
Should be a smooth drop-in replacement, we give the field an alias `imageUrl` in the query, so the rest of the app is none the wiser!

I didn't test the layer upload cache invalidation, but it seems pretty obvious to me, so ehh I'm just shipping it lmao
2022-10-12 12:41:27 -07:00
3428254318 Simplify modeling output when there's no items
This'll both hide sections that are empty (which just wasn't plausible for a long time), and print a happy lil message if there's no sections to show at all!
2022-10-12 12:09:15 -07:00
0a99668f00 Remove Modeling link from global header
We seem to have everything modeled now, and we have automatic modeling, so like… this is not a useful link for the general public anymore!

Instead, we'll just keep it a secret for us to check on the state of things!
2022-10-12 12:03:53 -07:00
1b0a6c8385 Mention automatic modeling on the homepage 2022-10-12 11:57:28 -07:00
a1844f76e0 Add /api/assetImageRedirect
Okay, this is gonna be a drop-in new backend for impress-asset-images.openneo.net, to enable Classic DTI to use the same images as DTI 2020!

This will enable us to stop generating images and uploading them to S3 just for Classic's sake, so we can turn those background processes off! And the new modeling script skips that anyway, so this is an important compatibility step for the new data that went out today!
2022-10-11 12:21:14 -07:00
29d9d498bf Use aws.impress-asset-images.openneo.net
We're gonna update impress-asset-images.openneo.net to perform redirects and stuff, so Classic DTI can start using the same images that DTI 2020 does.

That should enable us to stop relying on AWS for images, which is important because the new modeling script breaks that anyway :p but this will also let us turn off the image converters that run in the background all the time, and I'm excited for that too!
2022-10-11 12:19:39 -07:00
e8d7f6678d Auto-modeling script??
It seems to be working!! How exciting!! I'm just letting it run on stuff now :3

One important issue is that Classic DTI doesn't show images for items modeled this way, because we don't download the SWFs for it. But I wanna update it to stop using AWS anyway and do the same stuff 2020 does, I think we can do that pretty sneakily!
2022-10-11 11:13:10 -07:00
052cc242e4 Modeling page performance fix
Ok so, I kinda assumed that the query engine would only compute `all_species_ids_for_this_color` on the rows we actually returned, and it's a fast subquery so it's fine. But that was wrong! I think the query engine computing that for _every_ item, and _then_ filter out stuff with `HAVING`. Which makes sense, because the `HAVING` clause references it, so computing it makes sense!

In this change, we inline the subquery, so it only gets called if the other conditions in the `HAVING` clause don't fail first. That way, it only gets run when needed, and the query runs like 2x faster (~30sec instead of ~60sec), which gets us back inside some timeouts that were triggering around 1 minute and making the page fail.

However, this meant we no longer return `all_species_ids_for_this_color`, which we actually use to determine which species are _left_ to model for! So now, we have a loader that also basically runs the same query as that condition subquery.

A reasonable question would be, at this point, is the `HAVING` clause a good idea? would it be simpler to do the filtering in JS?

and I think it might be simpler, but I would guess noticeably worse performance, because I think we really do filter out a _lot_ of results with that `HAVING` clause—like basically all items, right? So to filter on the JS side, we'd be transferring data for all items over the wire, which… like, that's not even the worst dealbreaker, but it would certainly be noticed. This hypothesis could be wrong, but it's enough of a reason for me to not bother pursuring the refactor!
2022-10-10 20:15:16 -07:00
07e2c0f7b1 Add the /donate page
Just doing some house-cleaning on easy pages that need converted before DTI Classic can retire!
2022-09-25 08:05:38 -07:00
2b486ea218 New terms of use page
Remind me to link Classic DTI to this too tbh
2022-09-25 06:00:59 -07:00
1619c8f7bf Add page title to Privacy Policy 2022-09-25 05:07:26 -07:00
773ec8974f petOnNeopetsDotCom GQL improvements
We now support returning `null` from `petAppearance` when a pet genuinely has no customization data.

We also deprecate some old fields, and update our own call site to match.
2022-09-17 22:07:34 -07:00
d058f46906 Update Privacy Policy a bit
Remove the references to Auth0 unless you switched back to using it; and remove the references to Vercel and mention Linode instead.
2022-09-15 05:05:13 -07:00
4c343aee3e Stop doing the weird login bouncy bug
The item page got in a weird situation where this setting seemed to cause loading things _about_ `currentUser` to make the `useCurrentUser` GQL query flake out and say it's loading. This would make the layout bounce around a bunch while it tries to decide whether to show you the buttons or not.

I still don't love the UX of not having any loading state after login, but like… eh it's certainly better lmao
2022-09-15 04:59:32 -07:00
0176792cb9 Delete usePageTitle
We got rid of all its call sites, hooray!
2022-09-15 04:04:13 -07:00
16c9e1a25d Simplify page title & SSR for saved outfit
Now we can just use our usual pattern: preload some GraphQL data, and render the title and such in the page component itself! Whew!
2022-09-15 04:03:51 -07:00
e42f39f49b Use new page title syntax for list pages
I'm not gonna do SSR here, the pages aren't really designed for partial loading state yet. It could be done, but I'm too sleepy! And it's too much refactor at once.
2022-09-15 03:38:42 -07:00
70fc8cdefe Use new page title syntax for home page
In this case it's more that, the homepage doesn't need to do a reset anymore, our titles were always a bit too mutate-y 😅
2022-09-15 03:31:51 -07:00
73e7c8e8a3 Use new page title syntax for modeling 2022-09-15 03:31:00 -07:00
72211ae95a SSR for item trades page
I'm just moving through and using the new page title syntax, and getting some SSR in while I'm at it uwu
2022-09-15 03:30:14 -07:00
c5bd2695f6 A bit of SSR for the item page
Always been a bit annoyed to have even the item name load in so weird and slow 😅 this fixes it to come in much faster!

This also allows us to SSR the item name in the page title, since we've put it in the GraphQL cache at SSR time!
2022-09-15 03:05:14 -07:00
2887d952de Fix /outfits/new init + add more SSR
Whew, setting up a cute GraphQL SSR system! I feel like it strikes a good balance of not having actually too many moving parts, though it's still a bit extensive for the problem we're solving 😅

Anyway, by doing SSR at _all_, we solve the problem where Next's "Automatic Static Optimization" was causing problems by setting the outfit state to the default at the start of the page load.

So I figured, why not try to SSR things _good_?

Now, when you navigate to the /outfits/new page, Next.js will go get the necessary GraphQL data to show the image before even putting the page into view. This makes the image show up all snappy-like! (when images.neopets.com is behaving :p)

We could do this with the stuff in the items panel too, but it's a tiny bit more annoying in the code right now, so I'm just gonna not worry about it and see how this performs in practice!

This change _doesn't_ include making the images actually show up before JS loads in, I assume because our JS code tries to validate that the images have loaded before fading them in on the page. Idk if we want to do something smarter there for the SSR case, to try to get them loading in faster!
2022-09-15 02:46:14 -07:00
38170bfbb2 Migrate home page to Next.js routing
I think that means we're done? :3 Gonna uninstall react-router-dom next.
2022-09-15 00:43:05 -07:00
eb602556bf [WIP] Migrate outfit page, with known bug
Okay so there's a bug here where navigating directly to /outfits/new?species=X&color=Y will reset to a Blue Acara, because Next.js statically renders the Blue Acara on build, and then rehydrates a Blue Acara on load, and then updates the real page query in—and our state management for outfits doesn't *listen* to URL changes, it only *emits* them.

It'd be good to consider like… changing that? It's tricky because our state model is… not simple, when you consider that we have both local state and URL state and saved-outfit state in play. But it could be done! But there might be another option too. I'll take a look at this after moving the home page, which will give me the chance to see what the experience navigating in from there is like!
2022-09-15 00:27:49 -07:00
5d28c36e8a [WIP] Migrate single-list page to Next.js routing
Hey we're getting real close! :3

I accepted a small bug here where clicking the breadcrumb to "Items X wants" won't scroll down if the page isn't loaded yet. (e.g. you landed on this list page first). If you came *from* the lists index page though, then when you go back your stuff will be there already, so you should be fine. (It might also happen if the page loads fast enough, which in prod it might do?)

Just gonna leave it for now, because the workaround would be a lot! (have the page re-check the anchor once it's done loading)
2022-09-14 23:18:13 -07:00
e1ebb0eb9a [WIP] Migrate trade lists page to Next.js routing
We're getting so close! :3

There was some shared components in `UserItemListPage` that needed updated too, even though the rest of the page isn't migrated yet.
2022-09-14 23:04:58 -07:00
750ca208f1 [WIP] Migrate item trade pages to Next.js routing
One little tricky thing here was moving the `[itemId].tsx` page into the folder as `index.tsx`! Because we didn't have subpages before but now we do!
2022-09-14 22:56:45 -07:00
f1cfd1ac8f [WIP] Migrate /items/search to Next.js routing
Okay I actually screwed up the layouts thing a bit! Because right, they need to *share* a LayoutComponent in order to share the UI across the pages. This gets a bit tricky with wanting to change the margin, too. I'll address this with an upcoming refactor!
2022-09-14 22:44:48 -07:00
58edba6983 [WIP] Remove localStorage SSR error
Thankfully this wasn't a crasher since it was already in a try/catch, but it was logging a failure that didn't need to be logged! If `localStorage` isn't available (e.g. SSR), just use the initial value.
2022-09-14 22:35:33 -07:00
43ae248e87 Migrate /items/[itemId] to Next routing
The tricky part here was that `returnPartialData` seems to behave differently during SSR. On the page itself, this seems to cause us to always get back at least an empty object, but in SSR we can sometimes get null—which means that a LOT of code that expects the item object to exist while in loading state gets thrown off.

To keep this situation maximally clear, I added a bunch of null handling with `?.` to `ItemPageLayout`. An alternative would have been to check for null and put in an empty object if not, but this feels more resilient and more true to the situation.

The search bar here is a bit tricky, but is pretty straightforwardly adapted from how we did the layouts in App.js. Fingers crossed that it works as smoothly as expected when the search page is migrated too! (Right now typing in there is all messy because it hops over to the fallback route and does its whole separate thing.)
2022-09-14 22:26:59 -07:00
1dbc142f4f [WIP] Migrate /your-outfits to Next.js routing
This one was pretty boring! I was relieved to see the pagination changes seem to just work though 😅
2022-09-14 21:55:03 -07:00
02af99dded [WIP] Migrate /modeling to Next.js routing
Mostly easy, but with a link we needed to migrate in the `ItemCard` component! (I see one in `SquareItemCard` too, but I'll wait until it comes up.)
2022-09-14 19:52:10 -07:00
04c4e0c1f3 Migrate /support/petAppearances to Next.js routing
This was only a little bit tricky! I also noticed the hanger loading indicator being weird without having a container Box, so I added one.
2022-09-14 19:46:57 -07:00
1286b2e581 [WIP] Migrate /internal/assetImage to Next routing
This one is a bit trickier, because it doesn't use a page layout, and we had to make some fixes in OutfitMovieLayer! Nice to get a head-start on that though :3
2022-09-14 19:27:48 -07:00
65f3b9f819 [WIP] Migrate the conversion page
Another gimme!
2022-09-14 19:20:49 -07:00
eb8a0cf2a9 [WIP] Move Privacy Policy onto its own Next.js page
The first page moved over! Note that this broke navigation on the rest of the app, so don't deploy this until we're done!

The reason it broke was that we had to migrate GlobalHeader and GlobalFooter to the Next.js link & router stuff too, or else it crashed because it wasn't in a react-router-dom context.
2022-09-14 19:16:26 -07:00
8cd45d7082 Move a lot of App.js stuff into Next's _app.tsx
Just sorta idly poking at what it would take to make our Next setup a bit more normal. To start, I'm putting things in more of the normal place, and eyeing what it would take to switch to Next's built-in routing! So now `App.js` is pretty much entirely a routing file, potentially to be deleted once we move 🤔
2022-09-14 18:38:58 -07:00
2c54e356f9 Oops, fix mistakes turning on experimental log
I didn't notice that there was another place where "auth0" was set as the default, oops!

This caused logins to fail, because the cookie would be set, but the request wouldn't be sent with the correct `DTIAuthMode` header. So you'd stay logged in with your auth0 credentials, even though the UI was using your db cookies. Or something? Idk weird state mismatch.

Point being, fixed now!
2022-09-14 18:12:34 -07:00
aceb881b7c Default experimental login mode to On
Still leaving the toggle so users can hop back out to Auth0 if it turns out we broke stuff on 'em, but yeah I haven't heard anything bad from the experiment at all, and I think we don't need to bother with the gradual rollout! Let's just go!
2022-09-14 17:48:39 -07:00
0159bf18e0 Remove Cypress login hacks
We previously had a lil trick to help Cypress perform an Auth0 login without using the whole Auth0 UI. (I forget exactly why!)

With Cypress deleted, we don't need this code anymore!
2022-09-14 17:45:53 -07:00