Merge pull request #25 from caranicas/beta-react-filter-fix

fix filter and some styling
This commit is contained in:
caranicas 2022-09-18 19:25:42 -04:00 committed by GitHub
commit 7f3279f20f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 58 additions and 37 deletions

View File

@ -1,4 +1,4 @@
import React from "react"; import React, { useEffect, useState } from "react";
import { useImageCreate } from "../../../../../stores/imageCreateStore"; import { useImageCreate } from "../../../../../stores/imageCreateStore";
import { useCreateUI } from "../../creationPanelUIStore"; import { useCreateUI } from "../../creationPanelUIStore";
@ -13,6 +13,8 @@ export default function ImprovementSettings() {
state.isUsingFaceCorrection() state.isUsingFaceCorrection()
); );
const isUsingUpscaling = useImageCreate((state) => state.isUsingUpscaling());
const use_upscale = useImageCreate((state) => const use_upscale = useImageCreate((state) =>
state.getValueForRequestKey("use_upscale") state.getValueForRequestKey("use_upscale")
); );
@ -30,10 +32,25 @@ export default function ImprovementSettings() {
const improvementOpen = useCreateUI( const improvementOpen = useCreateUI(
(state) => state.isOpenAdvImprovementSettings (state) => state.isOpenAdvImprovementSettings
); );
const toggleImprovementOpen = useCreateUI( const toggleImprovementOpen = useCreateUI(
(state) => state.toggleAdvImprovementSettings (state) => state.toggleAdvImprovementSettings
); );
const [isFilteringDisabled, setIsFilteringDisabled] = useState(false);
// should probably be a store selector
useEffect(() => {
console.log("isUsingUpscaling", isUsingUpscaling);
console.log("isUsingFaceCorrection", isUsingFaceCorrection);
// if either are true we arent disabled
if (isUsingFaceCorrection || use_upscale) {
setIsFilteringDisabled(false);
} else {
setIsFilteringDisabled(true);
}
}, [isUsingFaceCorrection, isUsingUpscaling, setIsFilteringDisabled]);
return ( return (
<div> <div>
<button <button
@ -77,6 +94,7 @@ export default function ImprovementSettings() {
<div> <div>
<label> <label>
<input <input
disabled={isFilteringDisabled}
type="checkbox" type="checkbox"
checked={show_only_filtered_image} checked={show_only_filtered_image}
onChange={(e) => onChange={(e) =>

View File

@ -14,7 +14,7 @@ export const completedImagesMain = style({
}); });
export const imageContain = style({ export const imageContain = style({
width: "112px", width: "206px",
backgroundColor: "black", backgroundColor: "black",
display: "flex", display: "flex",
justifyContent: "center", justifyContent: "center",
@ -22,6 +22,8 @@ export const imageContain = style({
flexShrink: 0, flexShrink: 0,
border: "0 none", border: "0 none",
padding: "0", padding: "0",
marginLeft: vars.spacing.medium,
cursor: "pointer",
}); });
globalStyle(`${imageContain} img`, { globalStyle(`${imageContain} img`, {

View File

@ -17,35 +17,19 @@ export default function CompletedImages({
setCurrentDisplay, setCurrentDisplay,
}: CurrentDisplayProps) { }: CurrentDisplayProps) {
const _handleSetCurrentDisplay = (index: number) => { const _handleSetCurrentDisplay = (index: number) => {
debugger;
const image = images![index]; const image = images![index];
setCurrentDisplay(image); setCurrentDisplay(image);
}; };
console.log("COMP{LETED IMAGES", images);
return ( return (
<div className={completedImagesMain}> <div className={completedImagesMain}>
{images && {images &&
images.map((image, index) => { images.map((image, index) => {
// if (void 0 !== image) {
// return null;
// }
return ( return (
// <div className={imageContain} key={index} value={index} onClick={() => {
// debugger;
// const image = images[index];
// _handleSetCurrentDisplay(image);
// }}>
// <img src={image.data} alt={image.info.prompt} />
// </div>
<button <button
key={index} key={index}
className={imageContain} className={imageContain}
onClick={() => { onClick={() => {
console.log("CLICKED", index);
debugger;
_handleSetCurrentDisplay(index); _handleSetCurrentDisplay(index);
}} }}
> >

View File

@ -18,5 +18,5 @@ export const displayContainer = style({
}); });
export const previousImages = style({ export const previousImages = style({
height: "150px", // height: "150px",
}); });

View File

@ -11,7 +11,7 @@ export const AppLayout = style({
display: "grid", display: "grid",
// backgroundColor: "rgb(32, 33, 36)", // backgroundColor: "rgb(32, 33, 36)",
gridTemplateColumns: "400px 1fr", gridTemplateColumns: "400px 1fr",
gridTemplateRows: "100px 1fr 50px", gridTemplateRows: "100px 1fr 115px",
gridTemplateAreas: ` gridTemplateAreas: `
"header header header" "header header header"
"create display display" "create display display"
@ -21,7 +21,7 @@ export const AppLayout = style({
"@media": { "@media": {
"screen and (max-width: 800px)": { "screen and (max-width: 800px)": {
gridTemplateColumns: "1fr", gridTemplateColumns: "1fr",
gridTemplateRows: "100px 1fr 1fr 50px", gridTemplateRows: "100px 300px 1fr 100px",
gridTemplateAreas: ` gridTemplateAreas: `
"header" "header"
"create" "create"

View File

@ -87,6 +87,7 @@ interface ImageCreateState {
// isUsingUpscaling: () => boolean; // isUsingUpscaling: () => boolean;
toggleUseFaceCorrection: () => void; toggleUseFaceCorrection: () => void;
isUsingFaceCorrection: () => boolean; isUsingFaceCorrection: () => boolean;
isUsingUpscaling: () => boolean;
toggleUseRandomSeed: () => void; toggleUseRandomSeed: () => void;
isRandomSeed: () => boolean; isRandomSeed: () => boolean;
toggleUseAutoSave: () => void; toggleUseAutoSave: () => void;
@ -205,14 +206,25 @@ export const useImageCreate = create<ImageCreateState>(
request.save_to_disk_path = null; request.save_to_disk_path = null;
} }
if (void 0 === request.init_image) {
request.prompt_strength = undefined;
}
// a bit of a hack. figure out what a clean value to pass to the server is // a bit of a hack. figure out what a clean value to pass to the server is
// if we arent using upscaling clear the upscaling // if we arent using upscaling clear the upscaling
if (request.use_upscale === "") { if (request.use_upscale === "") {
request.use_upscale = null; request.use_upscale = null;
} }
if (void 0 === requestOptions.init_image) { // make sure you look above for the "null" value
request.prompt_strength = undefined; // this patches over a a backend issue if you dont ask for a filtered image
// you get nothing back
if (
null === request.use_upscale &&
null === request.use_face_correction
) {
request.show_only_filtered_image = false;
} }
return request; return request;
@ -237,6 +249,11 @@ export const useImageCreate = create<ImageCreateState>(
return isUsing; return isUsing;
}, },
isUsingUpscaling: () => {
const isUsing = get().getValueForRequestKey("use_upscale") != "";
return isUsing;
},
toggleUseRandomSeed: () => { toggleUseRandomSeed: () => {
set( set(
produce((state) => { produce((state) => {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long