Skip to content

refactor: remove legacy account model and migration util #1787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
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
8 changes: 0 additions & 8 deletions src/renderer/__mocks__/state-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ import {
Theme,
type Token,
} from '../types';
import type { EnterpriseAccount } from '../utils/auth/types';
import { Constants } from '../utils/constants';

export const mockEnterpriseAccounts: EnterpriseAccount[] = [
{
hostname: 'github.gitify.io' as Hostname,
token: '1234568790' as Token,
},
];

export const mockGitifyUser: GitifyUser = {
login: 'octocat',
name: 'Mona Lisa Octocat',
Expand Down
14 changes: 1 addition & 13 deletions src/renderer/context/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('renderer/context/App.tsx', () => {
const unsubscribeNotificationMock = jest.fn();

const mockDefaultState = {
auth: { accounts: [], enterpriseAccounts: [], token: null, user: null },
auth: { accounts: [] },
settings: mockSettings,
};

Expand Down Expand Up @@ -278,9 +278,6 @@ describe('renderer/context/App.tsx', () => {
expect(saveStateMock).toHaveBeenCalledWith({
auth: {
accounts: [],
enterpriseAccounts: [],
token: null,
user: null,
} as AuthState,
settings: {
...defaultSettings,
Expand Down Expand Up @@ -319,9 +316,6 @@ describe('renderer/context/App.tsx', () => {
expect(saveStateMock).toHaveBeenCalledWith({
auth: {
accounts: [],
enterpriseAccounts: [],
token: null,
user: null,
} as AuthState,
settings: {
...defaultSettings,
Expand Down Expand Up @@ -354,9 +348,6 @@ describe('renderer/context/App.tsx', () => {
expect(saveStateMock).toHaveBeenCalledWith({
auth: {
accounts: [],
enterpriseAccounts: [],
token: null,
user: null,
} as AuthState,
settings: {
...mockSettings,
Expand Down Expand Up @@ -390,9 +381,6 @@ describe('renderer/context/App.tsx', () => {
expect(saveStateMock).toHaveBeenCalledWith({
auth: {
accounts: [],
enterpriseAccounts: [],
token: null,
user: null,
} as AuthState,
settings: defaultSettings,
});
Expand Down
5 changes: 0 additions & 5 deletions src/renderer/context/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
} from '../types';
import type { Notification } from '../typesGitHub';
import { headNotifications } from '../utils/api/client';
import { migrateAuthenticatedAccounts } from '../utils/auth/migration';
import type {
LoginOAuthAppOptions,
LoginPersonalAccessTokenOptions,
Expand Down Expand Up @@ -63,9 +62,6 @@ import { zoomPercentageToLevel } from '../utils/zoom';

export const defaultAuth: AuthState = {
accounts: [],
token: null,
enterpriseAccounts: [],
user: null,
};

const defaultAppearanceSettings: AppearanceSettingsState = {
Expand Down Expand Up @@ -279,7 +275,6 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
);

const restoreSettings = useCallback(async () => {
await migrateAuthenticatedAccounts();
const existing = loadState();

// Restore settings before accounts to ensure filters are available before fetching notifications
Expand Down
18 changes: 1 addition & 17 deletions src/renderer/types.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
import type { OcticonProps } from '@primer/octicons-react';
import type { FC } from 'react';
import type { Notification, Reason } from './typesGitHub';
import type {
AuthMethod,
EnterpriseAccount,
PlatformType,
} from './utils/auth/types';
import type { AuthMethod, PlatformType } from './utils/auth/types';

declare const __brand: unique symbol;

type Brand<B> = { [__brand]: B };

export interface AuthState {
accounts: Account[];
/**
* @deprecated This attribute is deprecated and will be removed in a future release.
*/
token?: Token;
/**
* @deprecated This attribute is deprecated and will be removed in a future release.
*/
enterpriseAccounts?: EnterpriseAccount[];
/**
* @deprecated This attribute is deprecated and will be removed in a future release.
*/
user?: GitifyUser | null;
}

export type Branded<T, B> = T & Brand<B>;
Expand Down
164 changes: 0 additions & 164 deletions src/renderer/utils/auth/migration.test.ts

This file was deleted.

95 changes: 0 additions & 95 deletions src/renderer/utils/auth/migration.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/renderer/utils/auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,3 @@ export interface AuthTokenResponse {
hostname: Hostname;
token: Token;
}

/**
* @deprecated This type is deprecated and will be removed in a future release.
*/
export interface EnterpriseAccount {
hostname: Hostname;
token: Token;
}
Loading