There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): fix error message missing (#11166)
EYHN96fa1ffe6f1b
diff --git a/packages/frontend/component/src/ui/notification/desktop/notification-card.tsx b/packages/frontend/component/src/ui/notification/desktop/notification-card.tsxindex d8b57141e3..2ab268dd54 100644--- a/packages/frontend/component/src/ui/notification/desktop/notification-card.tsx+++ b/packages/frontend/component/src/ui/notification/desktop/notification-card.tsx@@ -55,7 +55,7 @@ export const DesktopNotificationCard = ({{icon}</div>) : null}- <div className={styles.title}>{title ?? errorTitle}</div>+ <div className={styles.title}>{title || errorTitle}</div>{action ? (<div className={clsx(styles.headAlignWrapper, styles.action)}>diff --git a/packages/frontend/component/src/ui/notification/mobile/notification-card.tsx b/packages/frontend/component/src/ui/notification/mobile/notification-card.tsxindex c5c3649ea9..d520ad4c69 100644--- a/packages/frontend/component/src/ui/notification/mobile/notification-card.tsx+++ b/packages/frontend/component/src/ui/notification/mobile/notification-card.tsx@@ -1,3 +1,4 @@+import { useI18n } from '@affine/i18n';import { CloseIcon, InformationFillDuotoneIcon } from '@blocksuite/icons/rc';import { useCallback, useState } from 'react';@@ -16,7 +17,14 @@ export function MobileNotificationCard({icon = <InformationFillDuotoneIcon />,iconColor,onDismiss,+ error,} = notification;+ const t = useI18n();+ const errorI18nKey = error ? (`error.${error.name}` as const) : undefined;+ const errorTitle =+ errorI18nKey && errorI18nKey in t+ ? t[errorI18nKey](error?.data)+ : undefined;const [animated, setAnimated] = useState(false);const [showDetail, setShowDetail] = useState(false);@@ -43,7 +51,9 @@ export function MobileNotificationCard({style={getCardVars(style, theme, iconColor)}><span className={styles.toastIcon}>{icon}</span>- <span className={styles.toastLabel}>{notification.title}</span>+ <span className={styles.toastLabel}>+ {notification.title || errorTitle}+ </span></div>);}@@ -62,7 +72,14 @@ const MobileNotifyDetail = ({message,footer,action,+ error,} = notification;+ const t = useI18n();+ const errorI18nKey = error ? (`error.${error.name}` as const) : undefined;+ const errorTitle =+ errorI18nKey && errorI18nKey in t+ ? t[errorI18nKey](error?.data)+ : undefined;const handleOpenChange = useCallback((open: boolean) => {@@ -91,7 +108,7 @@ const MobileNotifyDetail = ({<div className={styles.detailCard} onClick={e => e.stopPropagation()}><header className={styles.detailHeader}><span className={styles.detailIcon}>{icon}</span>- <span className={styles.detailLabel}>{title}</span>+ <span className={styles.detailLabel}>{title || errorTitle}</span><IconButton onClick={onClose} icon={<CloseIcon />} /></header><main className={styles.detailContent}>{message}</main>diff --git a/packages/frontend/i18n/src/i18next.ts b/packages/frontend/i18n/src/i18next.tsindex 6eac01e621..7854954045 100644--- a/packages/frontend/i18n/src/i18next.ts+++ b/packages/frontend/i18n/src/i18next.ts@@ -150,6 +150,16 @@ export function createI18nWrapper(getI18nFn: () => i18n) {return I18nMethod.t.bind(null, key);},+ has(self, key: string) {+ if (key in self) {+ return true;+ }+ const i18n = getI18nFn();+ if (i18n.exists(key)) {+ return true;+ }+ return false;+ },}) as typeof I18nMethod &ReturnType<typeof useAFFiNEI18N> & { [unknownKey: string]: () => string };}