mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
web: fix crashes when moving tabs
This commit is contained in:
@@ -220,21 +220,18 @@ function TabStrip() {
|
||||
}}
|
||||
onMove={(from, to) => {
|
||||
if (from === to) return;
|
||||
|
||||
useEditorStore.setState((state) => {
|
||||
const direction =
|
||||
to === 0 ? "start" : from > to ? "left" : "right";
|
||||
// if the tab where this tab is being dropped is pinned,
|
||||
// let's pin our tab too.
|
||||
if (state.sessions[to].pinned)
|
||||
state.sessions[from].pinned = true;
|
||||
|
||||
const [fromTab] = state.sessions.splice(from, 1);
|
||||
const newIndex =
|
||||
direction === "start" || direction === "right" ? to : to - 1;
|
||||
|
||||
// unpin the tab if it is moved.
|
||||
if (fromTab.pinned) fromTab.pinned = false;
|
||||
// if the tab where this tab is being dropped is pinned,
|
||||
// let's pin our tab too.
|
||||
if (state.sessions[to].pinned) fromTab.pinned = true;
|
||||
|
||||
state.sessions.splice(newIndex, 0, fromTab);
|
||||
state.sessions.splice(to, 0, fromTab);
|
||||
});
|
||||
}}
|
||||
onClose={() => useEditorStore.getState().closeSessions(session.id)}
|
||||
|
||||
@@ -84,19 +84,25 @@ export function ErrorComponent({ error, resetErrorBoundary }: FallbackProps) {
|
||||
How to fix it?
|
||||
</Text>
|
||||
<Text variant="body">{help.action}</Text>
|
||||
<Flex sx={{ gap: 1 }}>
|
||||
<Button
|
||||
variant="error"
|
||||
sx={{ alignSelf: "start", px: 30, mt: 1 }}
|
||||
onClick={() =>
|
||||
help.fix().catch((e) => {
|
||||
console.error(e);
|
||||
alert(errorToString(e));
|
||||
})
|
||||
}
|
||||
>
|
||||
Fix it
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
<Flex sx={{ gap: 1 }}>
|
||||
{help ? (
|
||||
<Button
|
||||
variant="error"
|
||||
sx={{ alignSelf: "start", px: 30, mt: 1 }}
|
||||
onClick={() =>
|
||||
help.fix().catch((e) => {
|
||||
console.error(e);
|
||||
alert(errorToString(e));
|
||||
})
|
||||
}
|
||||
>
|
||||
Fix it
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
{" "}
|
||||
<Button
|
||||
variant="secondary"
|
||||
sx={{ alignSelf: "start", px: 30, mt: 1 }}
|
||||
@@ -128,21 +134,9 @@ ${getDeviceInfo()}`
|
||||
>
|
||||
Contact support
|
||||
</Button>
|
||||
</Flex>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
variant="secondary"
|
||||
sx={{ alignSelf: "start", px: 30, mt: 1 }}
|
||||
onClick={() =>
|
||||
window.open("mailto:support@streetwriters.co", "_blank")
|
||||
}
|
||||
>
|
||||
Contact support
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
</BaseThemeProvider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user