Skip to content

Commit

Permalink
refactor notifications & instance error ui
Browse files Browse the repository at this point in the history
  • Loading branch information
blarfoon committed Apr 8, 2024
1 parent 4223cc4 commit 92eb900
Show file tree
Hide file tree
Showing 23 changed files with 460 additions and 264 deletions.
28 changes: 25 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ md-5 = "0.10.5"
murmurhash32 = { git = "https://github.com/gorilla-devs/murmurhash32", rev = "4dfdc49b727581bbdcad4a2315452a2c28db6093" }
nom = "7"
num_cpus = "1.16.0"
opener = "0.6.1"
opener = "0.7.0"
parking_lot = "0.12.1"
prisma-client-rust = { git = "https://github.com/gorilla-devs/prisma-client-rust", rev = "f74daf611f5ce8c20351eb05014b9176df2f0939", features = [
"sqlite-create-many",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ export const AccountsDropdown = (props: Props) => {
_variables,
context: { previousActiveUUID: string } | undefined
) => {
addNotification(error.message, "error");
addNotification({
name: error.message,
type: "error"
});

if (context?.previousActiveUUID) {
queryClient.setQueryData(
Expand All @@ -231,7 +234,10 @@ export const AccountsDropdown = (props: Props) => {
const accountEnrollCancelMutation = rspc.createMutation(() => ({
mutationKey: ["account.enroll.cancel"],
onError(error) {
addNotification(error.message, "error");
addNotification({
name: error.message,
type: "error"
});
setLoginDeviceCode(null);
setAddAccountStarting(false);
},
Expand All @@ -251,14 +257,20 @@ export const AccountsDropdown = (props: Props) => {
onError(error) {
if (enrollmentInProgress()) accountEnrollCancelMutation.mutate(undefined);
setAddAccountStarting(false);
addNotification(error.message, "error");
addNotification({
name: error.message,
type: "error"
});
}
}));

const accountEnrollFinalizeMutation = rspc.createMutation(() => ({
mutationKey: ["account.enroll.finalize"],
onError(error) {
addNotification(error.message, "error");
addNotification({
name: error.message,
type: "error"
});
},
onMutate() {
setLoadingAuthorization(false);
Expand Down Expand Up @@ -310,7 +322,10 @@ export const AccountsDropdown = (props: Props) => {
if (routeData.accounts.data?.length === 0) {
navigate("/");
} else {
addNotification(error.message, "error");
addNotification({
name: error.message,
type: "error"
});

if (context?.previousAccounts) {
queryClient.setQueryData(
Expand Down Expand Up @@ -362,14 +377,19 @@ export const AccountsDropdown = (props: Props) => {
reset();
accountEnrollCancelMutation.mutate(undefined);
if (error)
addNotification(
"somethign went wrong while adding an account",
"error"
);
addNotification({
name: "Could not add account",
content: error.toString(),
type: "error"
});
},
onError(error) {
reset();
if (error) addNotification(error?.message, "error");
if (error)
addNotification({
name: error?.message,
type: "error"
});
},
onComplete() {
setLoadingAuthorization(false);
Expand Down Expand Up @@ -633,7 +653,10 @@ export const AccountsDropdown = (props: Props) => {
(loginDeviceCode() as DeviceCode).userCode
);
}
addNotification("The code has been copied");
addNotification({
name: "Copied to clipboard",
type: "success"
});
}}
/>
</div>
Expand Down
5 changes: 4 additions & 1 deletion apps/desktop/packages/mainWindow/src/components/CopyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const CopyIcon = (props: Props) => {
onClick={() => {
if (!props.text) return;
navigator.clipboard.writeText(props.text as string);
addNotification("Copied to clipboard", "success");
addNotification({
name: "Copied to clipboard",
type: "success"
});
setClicked(true);
setTimeout(() => {
setClicked(false);
Expand Down
Loading

0 comments on commit 92eb900

Please sign in to comment.