A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fix crashes when moving tabs
Abdullah Atta5988640d3fe5
diff --git a/apps/web/src/components/editor/action-bar.tsx b/apps/web/src/components/editor/action-bar.tsxindex 36d4058ac..f586991f7 100644--- a/apps/web/src/components/editor/action-bar.tsx+++ b/apps/web/src/components/editor/action-bar.tsx@@ -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)}diff --git a/apps/web/src/components/error-boundary/index.tsx b/apps/web/src/components/error-boundary/index.tsxindex 3e8db053e..26c312fdd 100644--- a/apps/web/src/components/error-boundary/index.tsx+++ b/apps/web/src/components/error-boundary/index.tsx@@ -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>+ ) : (+ <>+ {" "}<Buttonvariant="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:[email protected]", "_blank")- }- >- Contact support- </Button>- </>- )}+ </>+ )}+ </Flex></Flex></BaseThemeProvider>);