disabled beta check for now

This commit is contained in:
caranicas 2022-09-18 11:14:17 -04:00
parent fd8c568d75
commit d027352d79
9 changed files with 56 additions and 78 deletions

View File

@ -44,12 +44,11 @@ export const toggleBetaConfig = async (branch: string) => {
const response = await fetch(`${API_URL}/app_config`, {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
'update_branch': branch
})
update_branch: branch,
}),
});
const data = await response.json();
return data;

View File

@ -1,70 +1,66 @@
import React, { useState, useEffect } from 'react';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import React, { useState, useEffect } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import {
KEY_CONFIG, getConfig,
KEY_TOGGLE_CONFIG, toggleBetaConfig
} from '../../../api';
KEY_CONFIG,
getConfig,
KEY_TOGGLE_CONFIG,
toggleBetaConfig,
} from "../../../api";
export default function BetaMode() {
// gate for the toggle
const [shouldSetCofig, setShouldSetConfig] = useState(false);
// next branch to get
// next branch to get
const [branchToGetNext, setBranchToGetNext] = useState("beta");
// our basic config
const { status: configStatus, data: configData } = useQuery([KEY_CONFIG], getConfig);
const queryClient = useQueryClient()
const { status: configStatus, data: configData } = useQuery(
[KEY_CONFIG],
getConfig
);
const queryClient = useQueryClient();
// the toggle config
const { status: toggleStatus, data: toggleData } = useQuery([KEY_TOGGLE_CONFIG], () => toggleBetaConfig(branchToGetNext), {
enabled: shouldSetCofig,
});
const { status: toggleStatus, data: toggleData } = useQuery(
[KEY_TOGGLE_CONFIG],
() => toggleBetaConfig(branchToGetNext),
{
enabled: shouldSetCofig,
}
);
// this is also in the Header Display
// TODO: make this a custom hook
useEffect(() => {
if (configStatus === 'success') {
if (configStatus === "success") {
const { update_branch } = configData;
if (update_branch === 'main') {
setBranchToGetNext('beta');
if (update_branch === "main") {
setBranchToGetNext("beta");
} else {
// setIsBeta(true);
setBranchToGetNext('main');
setBranchToGetNext("main");
}
}
}, [configStatus, configData]);
useEffect(() => {
if (toggleStatus === 'success') {
if (toggleData[0] == 'OK') {
if (toggleStatus === "success") {
if (toggleData[0] == "OK") {
// force a refetch of the config
queryClient.invalidateQueries([KEY_CONFIG])
queryClient.invalidateQueries([KEY_CONFIG]);
}
setShouldSetConfig(false);
}
}, [toggleStatus, toggleData, setShouldSetConfig]);
return (
<label>
<input
disabled={true}
type="checkbox"
checked={branchToGetNext === 'main'}
checked={branchToGetNext === "main"}
onChange={(e) => {
setShouldSetConfig(true);
}}
@ -73,4 +69,3 @@ export default function BetaMode() {
</label>
);
}

View File

@ -32,7 +32,6 @@ function SettingsList() {
<li className={AdvancedSettingItem}>
<BetaMode />
</li>
</ul>
);
}

View File

@ -10,7 +10,6 @@ import {
} from "./headerDisplay.css.ts";
export default function HeaderDisplay() {
const { status, data } = useQuery([KEY_CONFIG], getConfig);
const [version, setVersion] = useState("2.1.0");

View File

@ -7,7 +7,7 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { enableMapSet } from "immer";
import App from "./app";
import App from "./App";
import "./styles/index.css.ts";

View File

@ -1,22 +1,20 @@
import { recipe } from '@vanilla-extract/recipes';
import { recipe } from "@vanilla-extract/recipes";
export const button = recipe({
variants: {
color: {
neutral: { background: 'whitesmoke' },
brand: { background: 'blueviolet' },
accent: { background: 'slateblue' }
neutral: { background: "whitesmoke" },
brand: { background: "blueviolet" },
accent: { background: "slateblue" },
},
size: {
small: { padding: 12 },
medium: { padding: 16 },
large: { padding: 24 }
}
}
large: { padding: 24 },
},
},
});
// export const card = recipe({
// variants: {
// color: {

File diff suppressed because one or more lines are too long

View File

@ -19,19 +19,7 @@
<!-- THE STYLES ARE BEING USED IN THE REACT APP -->
<!-- WE NEED TO PORT OVER THE STYLES OVER TO THE REACT COMPONENTS -->
<style>
/* body {
font-family: Arial, Helvetica, sans-serif;
font-size: 11pt;
background-color: rgb(32, 33, 36);
color: #eee;
} */
a {
color: rgb(0, 102, 204);
}
a:visited {
color: rgb(0, 102, 204);
}
label {
/* label {
font-size: 10pt;
}
#prompt {
@ -73,7 +61,7 @@
}
#guidance_scale {
transform: translateY(30%);
}
} */
#outputMsg {
font-size: small;
}

File diff suppressed because one or more lines are too long