Skip to content

Commit

Permalink
Merge branch 'main' into dark-mode-adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
domyen committed Feb 14, 2024
2 parents 8f719f4 + 6025256 commit 29b0d8c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# v1.1.7 (Tue Feb 13 2024)

#### 🐛 Bug Fix

- Only throw errors for Git messages after a Project ID has been set [#186](https://github.com/chromaui/addon-visual-tests/pull/186) ([@thafryer](https://github.com/thafryer))

#### Authors: 1

- Jarel Fryer ([@thafryer](https://github.com/thafryer))

---

# v1.1.6 (Sun Feb 11 2024)

#### 🐛 Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,5 @@
"react-native"
]
},
"version": "1.1.6"
"version": "1.1.7"
}
14 changes: 7 additions & 7 deletions src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ export const Panel = ({ active, api }: PanelProps) => {
return withProviders(<Uninstalled />);
}

if (gitInfoError) {
// eslint-disable-next-line no-console
console.error(gitInfoError);
return withProviders(<GitNotFound gitInfoError={gitInfoError} />);
}

// Render the Authentication flow if the user is not signed in.
if (!accessToken) {
return withProviders(
Expand All @@ -102,7 +96,7 @@ export const Panel = ({ active, api }: PanelProps) => {
}

// Momentarily wait on addonState (should be very fast)
if (projectInfoLoading || !gitInfo) {
if (projectInfoLoading) {
return active ? <Spinner /> : null;
}

Expand All @@ -115,6 +109,12 @@ export const Panel = ({ active, api }: PanelProps) => {
/>
);

if (gitInfoError || !gitInfo) {
// eslint-disable-next-line no-console
console.error(gitInfoError);
return withProviders(<GitNotFound />);
}

if (projectUpdatingFailed) {
// These should always be set when we get this error
if (!configFile) throw new Error(`Missing config file after configuration failure`);
Expand Down
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function managerEntries(entry: string[] = []) {
const observeGitInfo = async (
interval: number,
callback: (info: GitInfo, prevInfo?: GitInfo) => void,
errorCallback: (e: Error) => void
errorCallback: (e: Error) => void,
projectId?: string
) => {
let prev: GitInfo | undefined;
let prevError: Error | undefined;
Expand All @@ -47,12 +48,12 @@ const observeGitInfo = async (
prevError = undefined;
timer = setTimeout(act, interval);
} catch (e: any) {
if (prevError?.message !== e.message) {
errorCallback(e);
if (projectId && prevError?.message !== e.message) {
console.error(`Failed to fetch git info, with error:\n${e}`);
errorCallback(e);
prev = undefined;
prevError = e;
}
prev = undefined;
prevError = e;
timer = setTimeout(act, interval);
}
};
Expand Down
12 changes: 7 additions & 5 deletions src/screens/GitNotFound/GitNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { Section } from "../../components/layout";
import { Screen } from "../../components/Screen";
import { Stack } from "../../components/Stack";
import { Text } from "../../components/Text";

interface GitNotFoundProps {
gitInfoError: Error;
}
import { useUninstallAddon } from "../Uninstalled/UninstallContext";

const InfoSection = styled(Section)(({ theme }) => ({
display: "flex",
Expand All @@ -40,7 +37,8 @@ const InfoSectionTextTitle = styled.b(() => ({
marginBottom: 2,
}));

export const GitNotFound = ({ gitInfoError }: GitNotFoundProps) => {
export const GitNotFound = () => {
const { uninstallAddon } = useUninstallAddon();
return (
<Screen footer={null}>
<Container>
Expand Down Expand Up @@ -70,6 +68,10 @@ export const GitNotFound = ({ gitInfoError }: GitNotFoundProps) => {
>
Visual tests requirements
</Link>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<Link withArrow onClick={() => uninstallAddon()}>
Uninstall
</Link>
</Stack>
</Container>
</Screen>
Expand Down

0 comments on commit 29b0d8c

Please sign in to comment.