Repository: gitify-app/gitify
Pull request #1471 (2024-08-16 00:50:30)

fix(deps): update dependency react-router-dom to v6.26.1
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [react-router-dom](https://togithub.com/remix-run/react-router) ([source](https://togithub.com/remix-run/react-router/tree/HEAD/packages/react-router-dom)) | [`6.26.0` -> `6.26.1`](https://renovatebot.com/diffs/npm/react-router-dom/6.26.0/6.26.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/react-router-dom/6.26.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-router-dom/6.26.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-router-dom/6.26.0/6.26.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-router-dom/6.26.0/6.26.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>remix-run/react-router (react-router-dom)</summary>

### [`v6.26.1`](https://togithub.com/remix-run/react-router/compare/react-router-dom@6.26.0...react-router-dom@6.26.1)

[Compare Source](https://togithub.com/remix-run/react-router/compare/react-router-dom@6.26.0...react-router-dom@6.26.1)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/gitify-app/gitify).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jeSJdfQ==-->



Patch:
diff --git a/package.json b/package.json
index c1f62f35..4118e887 100644
--- a/package.json
+++ b/package.json
@@ -114,7 +114,7 @@
     "react": "18.3.1",
     "react-dom": "18.3.1",
     "react-final-form": "6.5.9",
-    "react-router-dom": "6.26.0",
+    "react-router-dom": "6.26.1",
     "tailwind-merge": "2.5.2",
     "ts-loader": "9.5.1",
     "typescript": "5.5.4",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b109ac37..498ff03b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -51,8 +51,8 @@ importers:
         specifier: 6.5.9
         version: 6.5.9(final-form@4.20.10)(react@18.3.1)
       react-router-dom:
-        specifier: 6.26.0
-        version: 6.26.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+        specifier: 6.26.1
+        version: 6.26.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
       tailwind-merge:
         specifier: 2.5.2
         version: 2.5.2
@@ -563,8 +563,8 @@ packages:
     peerDependencies:
       react: '>=16.3'
 
-  '@remix-run/router@1.19.0':
-    resolution: {integrity: sha512-zDICCLKEwbVYTS6TjYaWtHXxkdoUvD/QXvyVZjGCsWz5vyH7aFeONlPffPdW+Y/t6KT0MgXb2Mfjun9YpWN1dA==}
+  '@remix-run/router@1.19.1':
+    resolution: {integrity: sha512-S45oynt/WH19bHbIXjtli6QmwNYvaz+vtnubvNpNDvUOoA/OWh6j1OikIP3G+v5GHdxyC6EXoChG3HgYGEUfcg==}
     engines: {node: '>=14.0.0'}
 
   '@sinclair/typebox@0.27.8':
@@ -2606,15 +2606,15 @@ packages:
   react-is@18.2.0:
     resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
 
-  react-router-dom@6.26.0:
-    resolution: {integrity: sha512-RRGUIiDtLrkX3uYcFiCIxKFWMcWQGMojpYZfcstc63A1+sSnVgILGIm9gNUA6na3Fm1QuPGSBQH2EMbAZOnMsQ==}
+  react-router-dom@6.26.1:
+    resolution: {integrity: sha512-veut7m41S1fLql4pLhxeSW3jlqs+4MtjRLj0xvuCEXsxusJCbs6I8yn9BxzzDX2XDgafrccY6hwjmd/bL54tFw==}
     engines: {node: '>=14.0.0'}
     peerDependencies:
       react: '>=16.8'
       react-dom: '>=16.8'
 
-  react-router@6.26.0:
-    resolution: {integrity: sha512-wVQq0/iFYd3iZ9H2l3N3k4PL8EEHcb0XlU2Na8nEwmiXgIUElEH6gaJDtUQxJ+JFzmIXaQjfdpcGWaM6IoQGxg==}
+  react-router@6.26.1:
+    resolution: {integrity: sha512-kIwJveZNwp7teQRI5QmwWo39A5bXRyqpH0COKKmPnyD2vBvDwgFXSqDUYtt1h+FEyfnE8eXr7oe0MxRzVwCcvQ==}
     engines: {node: '>=14.0.0'}
     peerDependencies:
       react: '>=16.8'
@@ -3816,7 +3816,7 @@ snapshots:
     dependencies:
       react: 18.3.1
 
-  '@remix-run/router@1.19.0': {}
+  '@remix-run/router@1.19.1': {}
 
   '@sinclair/typebox@0.27.8': {}
 
@@ -6142,16 +6142,16 @@ snapshots:
 
   react-is@18.2.0: {}
 
-  react-router-dom@6.26.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
+  react-router-dom@6.26.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
     dependencies:
-      '@remix-run/router': 1.19.0
+      '@remix-run/router': 1.19.1
       react: 18.3.1
       react-dom: 18.3.1(react@18.3.1)
-      react-router: 6.26.0(react@18.3.1)
+      react-router: 6.26.1(react@18.3.1)
 
-  react-router@6.26.0(react@18.3.1):
+  react-router@6.26.1(react@18.3.1):
     dependencies:
-      '@remix-run/router': 1.19.0
+      '@remix-run/router': 1.19.1
       react: 18.3.1
 
   react@18.3.1:
diff --git a/src/components/settings/AppearanceSettings.tsx b/src/components/settings/AppearanceSettings.tsx
index 6d5066be..1014776b 100644
--- a/src/components/settings/AppearanceSettings.tsx
+++ b/src/components/settings/AppearanceSettings.tsx
@@ -11,6 +11,7 @@ import { ipcRenderer, webFrame } from 'electron';
 import { type FC, useContext, useEffect, useState } from 'react';
 import { AppContext } from '../../context/App';
 import { Size, Theme } from '../../types';
+import { hasMultipleAccounts } from '../../utils/auth/utils';
 import { setTheme } from '../../utils/theme';
 import { zoomLevelToPercentage, zoomPercentageToLevel } from '../../utils/zoom';
 import { Button } from '../buttons/Button';
@@ -22,7 +23,7 @@ let timeout: NodeJS.Timeout;
 const DELAY = 200;
 
 export const AppearanceSettings: FC = () => {
-  const { settings, updateSetting } = useContext(AppContext);
+  const { auth, settings, updateSetting } = useContext(AppContext);
   const [zoomPercentage, setZoomPercentage] = useState(
     zoomLevelToPercentage(webFrame.getZoomLevel()),
   );
@@ -198,7 +199,8 @@ export const AppearanceSettings: FC = () => {
       <Checkbox
         name="showAccountHeader"
         label="Show account header"
-        checked={settings.showAccountHeader}
+        checked={settings.showAccountHeader || hasMultipleAccounts(auth)}
+        disabled={hasMultipleAccounts(auth)}
         onChange={(evt) =>
           updateSetting('showAccountHeader', evt.target.checked)
         }
diff --git a/src/context/App.tsx b/src/context/App.tsx
index b0291548..eb93a8e9 100644
--- a/src/context/App.tsx
+++ b/src/context/App.tsx
@@ -32,6 +32,7 @@ import {
   addAccount,
   authGitHub,
   getToken,
+  hasAccounts,
   refreshAccount,
   removeAccount,
 } from '../utils/auth/utils';
@@ -203,7 +204,7 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
   );
 
   const isLoggedIn = useMemo(() => {
-    return auth.accounts.length > 0;
+    return hasAccounts(auth);
   }, [auth]);
 
   const loginWithGitHubApp = useCallback(async () => {
diff --git a/src/utils/auth/utils.ts b/src/utils/auth/utils.ts
index 94a1965b..d79fcbce 100644
--- a/src/utils/auth/utils.ts
+++ b/src/utils/auth/utils.ts
@@ -241,3 +241,11 @@ export function isValidToken(token: Token) {
 export function getAccountUUID(account: Account): string {
   return btoa(`${account.hostname}-${account.user.id}-${account.method}`);
 }
+
+export function hasAccounts(auth: AuthState) {
+  return auth.accounts.length > 0;
+}
+
+export function hasMultipleAccounts(auth: AuthState) {
+  return auth.accounts.length > 1;
+}


Test patch:
diff --git a/src/components/settings/AppearanceSettings.test.tsx b/src/components/settings/AppearanceSettings.test.tsx
index 2cbba6fe..ce8afe30 100644
--- a/src/components/settings/AppearanceSettings.test.tsx
+++ b/src/components/settings/AppearanceSettings.test.tsx
@@ -1,7 +1,11 @@
 import { act, fireEvent, render, screen } from '@testing-library/react';
 import { webFrame } from 'electron';
 import { MemoryRouter } from 'react-router-dom';
-import { mockAuth, mockSettings } from '../../__mocks__/state-mocks';
+import {
+  mockAuth,
+  mockGitHubAppAccount,
+  mockSettings,
+} from '../../__mocks__/state-mocks';
 import { AppContext } from '../../context/App';
 import { AppearanceSettings } from './AppearanceSettings';
 
@@ -200,7 +204,9 @@ describe('routes/components/settings/AppearanceSettings.tsx', () => {
       render(
         <AppContext.Provider
           value={{
-            auth: mockAuth,
+            auth: {
+              accounts: [mockGitHubAppAccount],
+            },
             settings: mockSettings,
             updateSetting,
           }}
diff --git a/src/routes/__snapshots__/Settings.test.tsx.snap b/src/routes/__snapshots__/Settings.test.tsx.snap
index c3270ea9..74818bec 100644
--- a/src/routes/__snapshots__/Settings.test.tsx.snap
+++ b/src/routes/__snapshots__/Settings.test.tsx.snap
@@ -327,7 +327,9 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `
           class="flex items-center"
         >
           <input
+            checked=""
             class="size-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500 cursor-pointer"
+            disabled=""
             id="showAccountHeader"
             type="checkbox"
           />
@@ -337,6 +339,7 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `
             <label
               class="font-medium text-gray-700 dark:text-gray-200 cursor-pointer"
               for="showAccountHeader"
+              style="text-decoration: line-through;"
             >
               Show account header
             </label>
diff --git a/src/utils/auth/utils.test.ts b/src/utils/auth/utils.test.ts
index 460b0496..18965400 100644
--- a/src/utils/auth/utils.test.ts
+++ b/src/utils/auth/utils.test.ts
@@ -368,4 +368,37 @@ describe('utils/auth/utils.ts', () => {
       expect(auth.isValidToken('1234567890asdfg' as Token)).toBeFalsy();
     });
   });
+
+  describe('hasAccounts', () => {
+    it('should return true', () => {
+      expect(auth.hasAccounts(mockAuth)).toBeTruthy();
+    });
+
+    it('should validate false', () => {
+      expect(
+        auth.hasAccounts({
+          accounts: [],
+        }),
+      ).toBeFalsy();
+    });
+  });
+
+  describe('hasMultipleAccounts', () => {
+    it('should return true', () => {
+      expect(auth.hasMultipleAccounts(mockAuth)).toBeTruthy();
+    });
+
+    it('should validate false', () => {
+      expect(
+        auth.hasMultipleAccounts({
+          accounts: [],
+        }),
+      ).toBeFalsy();
+      expect(
+        auth.hasMultipleAccounts({
+          accounts: [mockGitHubCloudAccount],
+        }),
+      ).toBeFalsy();
+    });
+  });
 });