Skip to content

Commit

Permalink
Hide view button and show edit view when there is no content and not …
Browse files Browse the repository at this point in the history
…processing/generating.
  • Loading branch information
philipws committed Dec 9, 2024
1 parent 1592af9 commit 043c85c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions website/src/page/readable/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export default function ReadableNew() {
// this results in less clicks for the user particularly when adding a new row
React.useEffect(() => {
textState.forEach((textItem) => {
const hasNoInput = !textItem.input || textItem.input === "";
const hasNoInputOrOutput = ! hasContent(textItem);
const isNotLoading = !LoadingStatus.includes(textItem.status) && textItem.status;
if (hasNoInput && isNotLoading) {
if (hasNoInputOrOutput && isNotLoading) {
setItemViewState((prevState) => ({
...prevState,
[textItem.itemId]: { edit: true },
Expand All @@ -85,6 +85,12 @@ export default function ReadableNew() {
});
}, [textState, LoadingStatus]);

const hasContent = (textItem): boolean => {
const hasInput = textItem.input || ! textItem.input === "";
const hasOutput = textItem.output || ! textItem.output === "";
return hasInput || hasOutput;
}

async function createNewTextItem(order) {
const authSession = await fetchAuthSession();
try {
Expand Down Expand Up @@ -446,6 +452,7 @@ export default function ReadableNew() {
id: "mode",
iconName: "edit",
text: itemViewState[textItem.itemId]?.edit ? t("generic_view") : t("generic_edit"),
disabled: ! hasContent(textItem),
popoverFeedback: t("generic_viewing"),
pressedIconName: "transcript",
pressed: itemViewState[textItem.itemId]?.edit || false,
Expand Down

0 comments on commit 043c85c

Please sign in to comment.