Commit graph

704 commits

Author SHA1 Message Date
eaa4fbb575 Improve item page perf by caching valids in client
Okay, so getting the initial render down time for these faces is annoying, though I might come back to it…

But actually, the _worst_ part isn't the _initial_ render, which just kinda gets processed as part of the page navigation, right?

The _worst_ part is that we render it slowly _twice_: once on page load, as we send the `useAllValidPetPoses` fetch request; and then again when the fetch request ~instantly comes back from the network cache.

The fact that this requires a double-render, instead of just rendering with the cached valids data in the first place (like how our GraphQL client does), causes a second and highly-visible render of a slow-to-render UI!

So, here we update `useAllValidPetPoses` to cache its response in JS memory, similar in principle to how Apollo Client does. That way, we can return the valids instantly on the first render, if you already loaded them from the homepage or the wardrobe page or another item page!
2021-06-11 07:37:49 -07:00
caf0a8b815 Extract SpeciesFacesPicker to a new file
I wanna refactor how we do styles in it for perf reasons, and it's enough added complexity that I want it in its own file!
2021-06-11 06:58:12 -07:00
ab2dbeb02a Item page perf: memoize species faces
This is a pretty easy change, that makes re-renders faster when something about the item preview state changes!

That said, the initial render is still pretty slow, too, and that's the one that's bothering me more lol
2021-06-11 06:45:11 -07:00
07bf555a02 Oops, fix a perf regression in Hi-Res Mode!
Ah oops, because I forgot to set `hiResMode` here in the image preloader, we would preload the PNG, and _then_ load the SVG separately.

This doubled the effective image loading time in Hi-Res Mode!

Now, the image preloader respects hi-res mode, and will preload the SVG in the SVG case, and the PNG in the PNG case.
2021-06-11 05:52:53 -07:00
2375669cdf Only show SVG glitch message in hi-res mode
If you're not in hi-res mode, then you don't care about broken SVGs, because you wouldn't have seen them anyway!

We also update the message to reference Hi-Res Mode.
2021-06-08 08:32:30 -07:00
bed525d3ff Add hi-res mode setting, default off
We're just having too many glitchy SVGs for my taste, esp since TNT seems to just be using PNGs for now?

This change defaults us to using PNGs for users by default, with the option to use SVGs as a new "hi-res mode" setting.

This is our first ever setting, wow!

I'm also envisioning that like, if we get Fastly Image Optimizer set up, this could be a way to tune the quality of the incoming images.

We could also consider a setting to turn off animations altogether—like, just download the PNG instead of the movie, whereas right now we download the movie on the assumption that you might play it at any time.
2021-06-08 08:27:45 -07:00
efa8a4d499 Oops, don't show UC conflict glitch while loading
The way we were checking for UC compatibility issues, was also triggering while the appearance was still loading, so items didn't have any appearance layers yet!

Now, we check for loading before testing for that glitch.
2021-06-08 07:23:13 -07:00
277b8df838 Fix caching for homepage Latest Items
Oh right, adding user data to this query makes it uncacheable!

Split the query into the main public data, which will cache; and the user data, which will load in later.
2021-06-08 01:59:56 -07:00
a0be9942fb Add extra flair to trade matches
I refactor the hide-badge thing into 3 "trade matching modes". Then, the logic for whether to hide specific badges moves into the component, and we use that same flag to decide whether to show the big word "match"!
2021-06-08 01:23:31 -07:00
b762e11331 Add owns/wants badges on SquareItemCard
Boom, cute owns/wants badges on "Latest items", and the item search page, and trade matches!

I'm gonna add some additional flair to the trade match case, too!
2021-06-08 01:03:09 -07:00
4a22b50a77 Extract NC/PB/NP badge in SquareItemCard
This is just a small refactor to make `ItemThumbnail` more workable, because I'm gonna start working in it!
2021-06-08 00:33:23 -07:00
9a30b8c43f Fix bg color bug in homepage search field
This has been bugging me for a while lol, the background was leaking out of the corners!

I had applied the styles to the `InputGroup` because I didn't realize how Chakra implements this… I had assumed that the left/right elements wouldn't also get the background.

But it turns out, `InputGroup` uses `position: absolute` stuff, and uses padding to create visual space in the `Input` below them! So, this works perfect!
2021-06-08 00:20:23 -07:00
cb55881029 Switch back to $20/mo copy 2021-06-02 14:26:47 -07:00
da8cd8eda9 Extend the outfit deadline to Aug 1
I figure 1 month is fiiiine, but 2 months is less likely to catch people unawares, and I think that's important here.
2021-06-01 17:38:23 -07:00
e1d6981274 Fix mobile layout for outift URLs no-op message
Copied styles from the similar layout in the bulk converter tool! The status will flush to the right of the field header on desktop, and move below the input on mobile.
2021-06-01 17:35:29 -07:00
9191a5a65a Add UI for already converted outfit URLs
When the outfit image URL is already converted, we show a happy no-change message!
2021-06-01 17:32:27 -07:00
1865d62945 Clarify that outfit page links won't change
I add copy to indicate this, and update the tool to respond with a happy-looking no-change UI when you put in an outfit page link!
2021-06-01 17:29:13 -07:00
684bf5778f Use live outfit URLs in bulk converter 2021-05-26 20:00:01 -07:00
929e6c57a4 Use live outfit image URLs in single image converter 2021-05-26 19:57:06 -07:00
3603d6fd85 Explain the error condition 2021-05-26 19:11:04 -07:00
81b434347a Add title to OutfitUrlsPage 2021-05-26 19:03:21 -07:00
e829cc5525 Add a delay to bulk image conversion loading state
Right, yeah, in prod this is way faster, so the loading indicator is a distraction!
2021-05-25 05:49:47 -07:00
5f1980241f Oops, don't stretch preview when showing error
Right, oops, if you typed an invalid image url, the preview square would try to stretch to match! Now, it has a max-height to match its max-width.
2021-05-25 05:47:58 -07:00
11703140c4 Add more explainer copy to /outfit-urls 2021-05-25 05:46:10 -07:00
a08f4e3bd1 Fix controlled component warning
Mm right, when we first render the output, `imageUrl` is `undefined`, so the output textbox renders with `value={undefined}`, which is an "uncontrolled" component that the DOM is free to change.

In practice, this isn't an issue because the textbox has `isReadOnly`, so the user can't _actually_ change it. But it's still a good idea for consistency and clarity to use an empty string instead of `undefined`, and it removes warning spam from my console!
2021-05-25 05:30:57 -07:00
f9f8cdc553 Wire up the bulk outfit image converter
Heck yeah, it's looking great!! Good error handling too :) you can test the partial error case by changing some image URLs to have invalid IDs.
2021-05-25 05:28:02 -07:00
08eee30743 Lookup/petpage converter layout upgrades
Added placeholders, and improved copy styles

I tried a two-column view for desktop, but it's too busy with the long label text. This is clearer!
2021-05-25 04:17:09 -07:00
8b3cfe7118 Basic lookup/petpage design for /outfit-urls
Not converting yet, and only mobile design, but hitting save on it anyway!
2021-05-25 04:04:35 -07:00
01711fe0c2 Don't shrink error icon for long error text
Oops, previously the MajorErrorMessage was willing to shrink the width of the cute Grundo Programmer icon, to allow error messages with long words to avoid word breaks.

Here, we switch `1fr` for `minmax(0, 1fr)`, which allows the text zone to get smaller. (`1fr` is short for `minmax(auto, 1fr)`, which isn't capable of shrinking smaller than the natural value.)

Now, the error text is more willing to shrink by word-wrapping, than the image is by shrinking the image. Success!
2021-05-25 03:54:14 -07:00
390c21b53e Add image converter to /outfit-urls
Adding the tool that will help people convert one image at a time!
2021-05-25 03:35:32 -07:00
42b8c3833c Create /outfit-urls page
Gonna put an upgrade tool here for outfit images, and provide the URL in the replacement images on S3!
2021-05-24 21:07:30 -07:00
e5551a6847 Fix performance regression in SpeciesColorPicker
Oops, my cute API idea for `speciesPickerProps` breaks `React.memo`, of course!

We could fix this by having the caller memoize the `speciesPickerProps` object, but that's too unusual and error-prone. We could also fix this by writing a custom function for `React.memo` to determine whether props match, but that seems like overkill when there's only one actual prop we're using here in practice.

So yeah, I've updated `SpeciesColorPicker` to just accept `speciesTestId` and `colorTestId` props instead!

Note that actually this component _is_ still re-rendering too often, because of a Chakra bug I just discovered and reported! So this change won't immediately improve performance, but it should stop re-rendering too often once we _also_ upgrade Chakra after this bug is fixed. https://github.com/chakra-ui/chakra-ui/issues/4080
2021-05-24 17:50:31 -07:00
e3ae5e7116 extract PaginationToolbar from ItemSearchPage
wanna reuse in like outfits page
2021-05-21 00:50:55 -07:00
8f495d8302 Move getVisibleLayers to a new shared directory
This folder will include code shared by both the client-side app and the server!

The server isn't using it yet, but it will in a new API endpoint soon! I'm doing this in a separate commit to avoid lumping all the import-change noise into that commit.
2021-05-13 17:35:58 -07:00
3e981d82b4 Extract getVisibleLayers to its own file
I'm doing this in preparation for an API endpoint to build outfit images by ID. It'll need the same logic to decide which layers are visible, and the same GQL fragments to load the relevant data!
2021-05-13 17:33:54 -07:00
eec73d245b Add PB badge to items in search / homepage
Oh right, labeling PB items as NP is confusing! Here, we add a "PB" case to the lil badge on the corner of the item thumbnail, in item search page & homepage Newest Items.
2021-05-13 16:24:24 -07:00
c8feb9a7e0 Fix infinite loop when searching for Markings
Oops, we did an in-place sort on the search variables we passed to Apollo! This meant that Apollo's first read of the variables wouldn't match later reads, so it would always decide the variables had changed, causing an infinite re-render loop.

Remember to copy existing arrays before sorting! 😅

Incidentally, this only happened for Markings, by coincidence: it's the only (I think) searchable zone label with multiple zone IDs, that don't sort alphabetically the same as they sort numerically. This `.sort()` sorts them alphabetically, whereas they come in numerical order in `allZones`, because that's the order the GQL server returns them in `build-cached-data.js`.
2021-05-13 00:28:06 -07:00
b521f79a13 Don't auto-select the first item search filter
There have been usability problems with this search filter UI, and I think they mostly come down to people accidentally selecting filters when they don't mean to—sometimes pressing Enter to indicate that they're done typing, but accidentally selecting something.

Here, we remove that behavior, and additionally add a new behavior to clear the suggestions on pressing Enter.
2021-05-12 23:08:54 -07:00
7ec4bfcf64 Announce outfit saving on homepage 2021-05-05 00:23:41 -07:00
65af7ef64c Add general error message for wardrobe crashes
Boom, pulled some stuff out into util! Now we also have error boundaries in both panels of the wardrobe page.

You can test this one by visiting `/outfits/new?send-test-error-for-sentry`, just like on the home page! Util component for fake errors owo
2021-05-05 00:22:28 -07:00
6dc6ad2578 Add general error message when page crashes
Previously, we would tear down to a blank white page. Now, for errors within most page content, we show a cute error message with a grundo programmer!

To test, visit `/?send-test-error-for-sentry`, which will trigger an intentional render error on the home page.

Note that this does _not_ cover pages that don't use PageLayout, namely the wardrobe page! I'll want to add other boundaries there…
2021-05-05 00:09:09 -07:00
aa0a66fe6d Oops, fix a crasher on item search page
Crashes on clearing the search box. I really thought I fixed this when I refactored `forceReset` to be a function, but I guess I missed it when I went back-and-forth deciding whether to actually do the refactor!
2021-05-04 18:56:00 -07:00
e63c4ea68f Stop adding extras to Your Outfits after save 2021-05-04 18:38:14 -07:00
e7ad4dc39e Avoid extra rename action logs 2021-05-04 16:32:01 -07:00
76aca48b43 Warn user of unsaved outfit changes 2021-05-04 16:31:48 -07:00
8e18262db0 Fix making changes while outfit is saving
Before this, if you made a change while the outfit was auto-saving, it would reset your changes back and forth in an infinite loop, oops!

This was because the response from the save would reset the outfit state to match, but the _debounced_ outfit state would still show the user's changes, so we'd trigger another save. And then the same thing would happen in reverse, and back and forth again!
2021-05-04 13:43:32 -07:00
3088b97ad2 Enable auto-saving while searching for items
This means hoisting `useOutfitSaving` up to the top of the page! We had it down lower for iteration convenience to start :)
2021-05-04 13:28:29 -07:00
b6274193d5 Hide outfit thumbnail in wardrobe after loading
Oops, it was possible after saving an outfit to get into a state where we would show the `<OutfitThumbnailIfCached />` behind the outfit even after it was saved, and then removing items would look weird until auto-saving caught up.

We had used the `backdrop` property because we wanted smoother partial load-ins, but for now I'm just fixing this by switching it to `placeholder`, which already has the right loading-only behavior.

This was also the only call site for `backdrop`, so I've removed it!
2021-05-04 12:33:13 -07:00
995a2b8a3a Fix infinite loop bug on initial outfit save
Oops, the sequence here was:
1) Save a new outfit
2) The debounced outfit state still contains id=null, which doesn't match the saved outfit, which triggers an auto-save
3) And now again, the debounced outfit state contains the _previous_ saved outfit ID, but the saved outfit has a _new_ ID, so we save the _previous_ outfit again

and back and forth forever.

Right, ok, simple change: if the saved outfit ID changes, reset the debounced state immediately, so it can't even be out of sync in the first place! (I also considered checking it in the condition, but I didn't really understand what the timing properties of being out of sync due to debouncing would be, and it seemed to not represent the reality I want.)
2021-05-04 12:33:13 -07:00
1d97988383 Finish outfit auto-saving!
Hope it actually work-works lol

Did some refactors in useOutfitState to support the new reset action we do after auto-saving, in case the server tweaked things like the name.
2021-05-04 12:33:13 -07:00