InvokeAI/invokeai/frontend/web
psychedelicious 8d3bec57d5 feat(ui): store only image name in parameters
Images that are used as parameters (e.g. init image, canvas images) are stored as full `ImageDTO` objects in state, separate from and duplicating any object representing those same objects in the `imagesSlice`.

We cannot store only image names as parameters, then pull the full `ImageDTO` from `imagesSlice`, because if an image is not on a loaded page, it doesn't exist in `imagesSlice`. For example, if you scroll down a few pages in the gallery and send that image to canvas, on reloading the app, the canvas will be unable to load that image.

We solved this temporarily by storing the full `ImageDTO` object wherever it was needed, but this is both inefficient and allows for stale `ImageDTO`s across the app.

One other possible solution was to just fetch the `ImageDTO` for all images at startup, and insert them into the `imagesSlice`, but then we run into an issue where we are displaying images in the gallery totally out of context.

For example, if an image from several pages into the gallery was sent to canvas, and the user refreshes, we'd display the first 20 images in gallery. Then to populate the canvas, we'd fetch that image we sent to canvas and add it to `imagesSlice`. Now we'd have 21 images in the gallery: 1 to 20 and whichever image we sent to canvas. Weird.

Using `rtk-query` solves this by allowing us to very easily fetch individual images in the components that need them, and not directly interact with `imagesSlice`.

This commit changes all references to images-as-parameters to store only the name of the image, and not the full `ImageDTO` object. Then, we use an `rtk-query` generated `useGetImageDTOQuery()` hook in each of those components to fetch the image.

We can use cache invalidation when we mutate any image to trigger automated re-running of the query and all the images are automatically kept up to date.

This also obviates the need for the convoluted URL fetching scheme for images that are used as parameters. The `imagesSlice` still need this handling unfortunately.
2023-06-22 16:25:49 +10:00
..
.husky feat(ui): migrate theming to chakra ui 2023-03-06 20:03:39 +11:00
.yarn/releases all files migrated; tweaks needed 2023-03-03 00:02:15 -05:00
config build(ui): add style injection plugin 2023-05-12 17:56:18 +10:00
dist merge with main 2023-06-08 21:08:43 -04:00
docs dummy commit to make github actions run 2023-06-04 22:55:35 +10:00
patches chore(ui): clean up unused files/packages 2023-05-15 22:48:06 +10:00
public/locales feat(ui): enabledSchedulers -> favoriteSchedulers 2023-06-18 20:01:05 +10:00
src feat(ui): store only image name in parameters 2023-06-22 16:25:49 +10:00
static move static into invokeai.frontend.web directory for dist install 2023-05-22 16:48:17 -04:00
tests Partial migration of UI to nodes API (#3195) 2023-04-22 13:10:20 +10:00
__init__.py Revert "Merge branch 'main' into bugfix/reenable-ckpt-conversion-to-ram" 2023-03-06 14:29:39 +13:00
.eslintignore move static into invokeai.frontend.web directory for dist install 2023-05-22 16:48:17 -04:00
.eslintrc.js feat(ui): wip resizable pinnable drawer 2023-03-12 20:13:37 +11:00
.gitignore build(ui): add yalc to gitignore 2023-05-11 11:55:51 +10:00
.prettierignore Partial migration of UI to nodes API (#3195) 2023-04-22 13:10:20 +10:00
.prettierrc.js feat(ui): migrate theming to chakra ui 2023-03-06 20:03:39 +11:00
.yarnrc all files migrated; tweaks needed 2023-03-03 00:02:15 -05:00
.yarnrc.yml all files migrated; tweaks needed 2023-03-03 00:02:15 -05:00
favicon.ico all files migrated; tweaks needed 2023-03-03 00:02:15 -05:00
index.html feat(ui): migrate theming to chakra ui 2023-03-06 20:03:39 +11:00
package.json feat: Add Mantine Support 2023-06-14 14:14:24 +10:00
stats.html merge with main 2023-06-08 21:08:43 -04:00
tsconfig.json build(ui): add style injection plugin 2023-05-12 17:56:18 +10:00
tsconfig.node.json build(ui): fix types exports 2023-04-28 21:56:43 +10:00
vite.config.ts build(ui): treeshake lodash via lodash-es 2023-04-28 21:56:43 +10:00
yarn.lock feat: Add Mantine Support 2023-06-14 14:14:24 +10:00