Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,24 @@ test('blocks autosave when markup has hard reference errors', async () => {
?.firstChild as HTMLElement;
await waitFor(() => expect(tbody.children.length).toBeTruthy());

// Load saved segment data with an out-of-passage ref ("9:9") into the table.
act(() => {
if (mockPlayerAction) {
mockPlayerAction(
'{"regions":"[{\\"start\\":0,\\"end\\":5,\\"label\\":\\"9:9\\"}]"}',
false
true
);
}
});

// Simulate a user boundary edit (init=false) so checkBlockersAndScheduleAutosave
// runs with "9:9" still in the table — the blocker should be detected and warned.
act(() => {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot claims this test had previously been passing only by accident

if (mockPlayerAction) {
mockPlayerAction('{"regions":"[{\\"start\\":0,\\"end\\":6}]"}', false);
}
});

await waitFor(() => {
expect(mockShowMessage).toHaveBeenCalledWith(
expect.anything(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export function PassageDetailMarkVerses({ width }: MarkVersesProps) {
const {
toolChanged,
toolsChanged,
isChanged,
saveRequested,
saveCompleted,
clearRequested,
Expand Down Expand Up @@ -616,7 +615,10 @@ export function PassageDetailMarkVerses({ width }: MarkVersesProps) {
if (reset) {
resetSegments(regions);
}
if (!init && !isChanged(verseToolId)) toolChanged(verseToolId);
if (!init) {
toolChanged(verseToolId);
checkBlockersAndScheduleAutosave();
}
}
};

Expand Down Expand Up @@ -741,6 +743,7 @@ export function PassageDetailMarkVerses({ width }: MarkVersesProps) {
setData(newData);
setSegments();
toolChanged(verseToolId);
checkBlockersAndScheduleAutosave();
}
};

Expand Down Expand Up @@ -845,8 +848,8 @@ export function PassageDetailMarkVerses({ width }: MarkVersesProps) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [toolsChanged, scheduleAutosave]);

useEffect(() => {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin flagged that we are now further diverging from the mobile version, which still uses an effect for this. But the logic is already different enough in the mobile version that I was thinking this is fine

if (!isChanged(verseToolId) || !hasPermission || savingRef.current) return;
const checkBlockersAndScheduleAutosave = () => {
if (!hasPermission) return;
const allIssues = checkRefs();
const blockers = checkAutosaveBlockers();
setSaveIssues(allIssues);
Expand Down Expand Up @@ -885,8 +888,7 @@ export function PassageDetailMarkVerses({ width }: MarkVersesProps) {
setIssuesDialogOpen(false);
}
scheduleAutosave();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [toolsChanged, hasPermission, scheduleAutosave]);
};

return Boolean(mediafileId) && passType !== PassageTypeEnum.NOTE ? (
<Box>
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/src/hoc/SnackBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react-refresh/only-export-components */
import { useState, useEffect } from 'react';
import { useState, useEffect, Fragment } from 'react';
import { useGlobal } from '../context/useGlobal';
import {
Snackbar as MuiSnackbar,
Expand Down Expand Up @@ -45,8 +45,9 @@ function SimpleSnackbar(props: ISBProps) {
};

useEffect(() => {
if ((message?.type === 'span') !== open) {
setOpen(!open);
const hasMessage = !!message && message.type !== Fragment;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little nervous about this change because the SnackBar is used in so many different places. But it definitely seems like a bug that previously toasts weren't appearing because their messages were wrapped in non-spans

if (hasMessage !== open) {
setOpen(hasMessage);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [message]);
Expand Down
Loading