Skip to content

Commit

Permalink
remove unused error message
Browse files Browse the repository at this point in the history
  • Loading branch information
moscicky committed Aug 14, 2024
1 parent ad322ff commit bd0e569
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
12 changes: 6 additions & 6 deletions hermes-console/src/composables/sync/use-sync/useSync.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('useSync', () => {
await waitFor(() => {
expectNotificationDispatched(notificationStore, {
type: 'error',
title: 'notifications.sync.failure',
title: 'notifications.consistency.sync.failure',
});
});
});
Expand All @@ -70,7 +70,7 @@ describe('useSync', () => {
await waitFor(() => {
expectNotificationDispatched(notificationStore, {
type: 'error',
title: 'notifications.sync.failure',
title: 'notifications.consistency.sync.failure',
});
});
});
Expand All @@ -96,7 +96,7 @@ describe('useSync', () => {
await waitFor(() => {
expectNotificationDispatched(notificationStore, {
type: 'error',
title: 'notifications.sync.failure',
title: 'notifications.consistency.sync.failure',
});
});
});
Expand All @@ -119,7 +119,7 @@ describe('useSync', () => {
await waitFor(() => {
expectNotificationDispatched(notificationStore, {
type: 'success',
text: 'notifications.sync.success',
text: 'notifications.consistency.sync.success',
});
});
});
Expand All @@ -142,7 +142,7 @@ describe('useSync', () => {
await waitFor(() => {
expectNotificationDispatched(notificationStore, {
type: 'success',
text: 'notifications.sync.success',
text: 'notifications.consistency.sync.success',
});
});
});
Expand All @@ -168,7 +168,7 @@ describe('useSync', () => {
await waitFor(() => {
expectNotificationDispatched(notificationStore, {
type: 'success',
text: 'notifications.sync.success',
text: 'notifications.consistency.sync.success',
});
});
});
Expand Down
20 changes: 6 additions & 14 deletions hermes-console/src/composables/sync/use-sync/useSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import {
syncTopic as doSyncTopic,
} from '@/api/hermes-client';
import { groupName } from '@/utils/topic-utils/topic-utils';
import { ref, type Ref } from 'vue';
import { useConsistencyStore } from '@/store/consistency/useConsistencyStore';
import { useGlobalI18n } from '@/i18n';
import { useNotificationsStore } from '@/store/app-notifications/useAppNotifications';

export interface UseSync {
errorMessage: Ref<Error | null | undefined>;
syncGroup: (groupName: string, primaryDatacenter: string) => Promise<boolean>;
syncTopic: (
topicQualifiedName: string,
Expand All @@ -25,28 +23,25 @@ export interface UseSync {
}

export function useSync(): UseSync {
const errorMessage: Ref<Error | null | undefined> = ref();

const notificationStore = useNotificationsStore();
const consistencyStore = useConsistencyStore();

const syncGroup = async (groupName: string, primaryDatacenter: string) => {
try {
await doSyncGroup(groupName, primaryDatacenter);
await notificationStore.dispatchNotification({
text: useGlobalI18n().t('notifications.sync.success', {
text: useGlobalI18n().t('notifications.consistency.sync.success', {
group: groupName,
}),
type: 'success',
});
await consistencyStore.refresh(groupName);
return true;
} catch (e: any) {
errorMessage.value = e as Error;
dispatchErrorNotification(
e,
notificationStore,
useGlobalI18n().t('notifications.sync.failure', {
useGlobalI18n().t('notifications.consistency.sync.failure', {
group: groupName,
}),
);
Expand All @@ -62,19 +57,18 @@ export function useSync(): UseSync {
try {
await doSyncTopic(topicQualifiedName, primaryDatacenter);
await notificationStore.dispatchNotification({
text: useGlobalI18n().t('notifications.sync.success', {
text: useGlobalI18n().t('notifications.consistency.sync.success', {
group,
}),
type: 'success',
});
await consistencyStore.refresh(group);
return true;
} catch (e: any) {
errorMessage.value = e as Error;
dispatchErrorNotification(
e,
notificationStore,
useGlobalI18n().t('notifications.sync.failure', {
useGlobalI18n().t('notifications.consistency.sync.failure', {
group,
}),
);
Expand All @@ -95,19 +89,18 @@ export function useSync(): UseSync {
primaryDatacenter,
);
await notificationStore.dispatchNotification({
text: useGlobalI18n().t('notifications.sync.success', {
text: useGlobalI18n().t('notifications.consistency.sync.success', {
group,
}),
type: 'success',
});
await consistencyStore.refresh(group);
return true;
} catch (e: any) {
errorMessage.value = e as Error;
dispatchErrorNotification(
e,
notificationStore,
useGlobalI18n().t('notifications.sync.failure', {
useGlobalI18n().t('notifications.consistency.sync.failure', {
group,
}),
);
Expand All @@ -116,7 +109,6 @@ export function useSync(): UseSync {
};

return {
errorMessage,
syncGroup,
syncSubscription,
syncTopic,
Expand Down
8 changes: 5 additions & 3 deletions hermes-console/src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,11 @@ const en_US = {
failure: "Couldn't delete topic {topic}",
},
},
sync: {
success: 'Synchronization of {group} succeeded',
failure: 'Synchronization of {group} failed',
consistency: {
sync: {
success: 'Synchronization of {group} succeeded',
failure: 'Synchronization of {group} failed',
},
},
subscription: {
create: {
Expand Down

0 comments on commit bd0e569

Please sign in to comment.