@blocklet/ui-react 2.13.58 → 2.13.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,34 +21,31 @@ function NotificationItem({
21
21
  onChange,
22
22
  isMobile
23
23
  }) {
24
- return /* @__PURE__ */ jsx(
25
- Switch,
26
- {
27
- checked: value,
28
- labelProps: {
29
- label: /* @__PURE__ */ jsxs(
30
- Typography,
31
- {
32
- color: "text.primary",
33
- sx: {
34
- fontSize: 14,
35
- display: "flex",
36
- flexWrap: isMobile ? "wrap" : "nowrap",
37
- columnGap: 1,
38
- flex: 1,
39
- whiteSpace: isMobile ? "normal" : "nowrap"
40
- },
41
- children: [
42
- title,
43
- description
44
- ]
45
- }
46
- )
47
- },
48
- size: "small",
49
- onChange
50
- }
51
- );
24
+ const handleClick = useMemoizedFn((event) => {
25
+ event.stopPropagation();
26
+ });
27
+ return /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", gap: 1, children: [
28
+ /* @__PURE__ */ jsx(Switch, { checked: value, size: "small", onChange }),
29
+ /* @__PURE__ */ jsxs(
30
+ Typography,
31
+ {
32
+ color: "text.primary",
33
+ sx: {
34
+ fontSize: 14,
35
+ display: "flex",
36
+ flexWrap: isMobile ? "wrap" : "nowrap",
37
+ columnGap: 1,
38
+ flex: 1,
39
+ whiteSpace: isMobile ? "normal" : "nowrap"
40
+ },
41
+ onClick: handleClick,
42
+ children: [
43
+ title,
44
+ description
45
+ ]
46
+ }
47
+ )
48
+ ] });
52
49
  }
53
50
  export default function Notification({ user, isMobile }) {
54
51
  const { locale } = useLocaleContext();
@@ -1,12 +1,13 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import Badge from "@mui/material/Badge";
3
3
  import PropTypes from "prop-types";
4
- import { useCallback, useEffect } from "react";
4
+ import { useCallback, useEffect, useMemo } from "react";
5
5
  import { IconButton } from "@mui/material";
6
6
  import { useSnackbar } from "notistack";
7
7
  import NotificationsOutlinedIcon from "@arcblock/icons/lib/Notification";
8
8
  import { useCreation } from "ahooks";
9
9
  import { EVENTS, WELLKNOWN_SERVICE_PATH_PREFIX } from "@abtnode/constant";
10
+ import useBrowser from "@arcblock/react-hooks/lib/useBrowser";
10
11
  import { joinURL, withQuery } from "ufo";
11
12
  import { useListenWsClient } from "./ws.js";
12
13
  import NotificationSnackbar from "../Notifications/Snackbar.js";
@@ -23,6 +24,10 @@ export default function NotificationAddon({ session = {} }) {
23
24
  const { unReadCount, user, setUnReadCount } = session;
24
25
  const userDid = useCreation(() => user?.did, [user]);
25
26
  const { enqueueSnackbar } = useSnackbar();
27
+ const browser = useBrowser();
28
+ const hiddenNotificationToast = useMemo(() => {
29
+ return browser.arcSphere || browser.wallet;
30
+ }, [browser]);
26
31
  const serverVersion = useCreation(() => {
27
32
  return window.blocklet?.serverVersion;
28
33
  }, []);
@@ -42,7 +47,7 @@ export default function NotificationAddon({ session = {} }) {
42
47
  if (notificationReceiver === userDid) {
43
48
  setUnReadCount((x) => x + 1);
44
49
  const isCompatible = compareVersions(serverVersion, "1.16.42-beta-20250407");
45
- if (notification.source === "component" && isCompatible) {
50
+ if (!hiddenNotificationToast && notification.source === "component" && isCompatible) {
46
51
  const link = getNotificationLink(notification);
47
52
  const { severity, description } = notification || {};
48
53
  const disableAutoHide = ["error", "warning"].includes(severity) || notification.sticky;
@@ -55,7 +60,7 @@ export default function NotificationAddon({ session = {} }) {
55
60
  }
56
61
  }
57
62
  },
58
- [userDid, setUnReadCount, enqueueSnackbar, serverVersion]
63
+ [userDid, setUnReadCount, enqueueSnackbar, serverVersion, hiddenNotificationToast]
59
64
  );
60
65
  const readListenCallback = useCallback(
61
66
  (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.13.58",
3
+ "version": "2.13.59",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@abtnode/constant": "^1.16.43",
36
36
  "@abtnode/util": "^1.16.43",
37
- "@arcblock/bridge": "^2.13.58",
38
- "@arcblock/react-hooks": "^2.13.58",
37
+ "@arcblock/bridge": "^2.13.59",
38
+ "@arcblock/react-hooks": "^2.13.59",
39
39
  "@arcblock/ws": "^1.20.11",
40
40
  "@blocklet/constant": "^1.16.43",
41
41
  "@blocklet/did-space-react": "^1.0.56",
@@ -94,5 +94,5 @@
94
94
  "jest": "^29.7.0",
95
95
  "unbuild": "^2.0.0"
96
96
  },
97
- "gitHead": "a1251dcb82603ceef7a4a4ab58efb3f53b103a4e"
97
+ "gitHead": "e00efa251020006bdc76353ef6c64212529ebddd"
98
98
  }
@@ -31,29 +31,28 @@ function NotificationItem({
31
31
  onChange: (event: ChangeEvent<HTMLInputElement>) => void;
32
32
  isMobile: boolean;
33
33
  }) {
34
+ const handleClick = useMemoizedFn((event: React.MouseEvent) => {
35
+ event.stopPropagation();
36
+ });
37
+
34
38
  return (
35
- <Switch
36
- checked={value}
37
- labelProps={{
38
- label: (
39
- <Typography
40
- color="text.primary"
41
- sx={{
42
- fontSize: 14,
43
- display: 'flex',
44
- flexWrap: isMobile ? 'wrap' : 'nowrap',
45
- columnGap: 1,
46
- flex: 1,
47
- whiteSpace: isMobile ? 'normal' : 'nowrap',
48
- }}>
49
- {title}
50
- {description}
51
- </Typography>
52
- ),
53
- }}
54
- size="small"
55
- onChange={onChange}
56
- />
39
+ <Box display="flex" alignItems="center" gap={1}>
40
+ <Switch checked={value} size="small" onChange={onChange} />
41
+ <Typography
42
+ color="text.primary"
43
+ sx={{
44
+ fontSize: 14,
45
+ display: 'flex',
46
+ flexWrap: isMobile ? 'wrap' : 'nowrap',
47
+ columnGap: 1,
48
+ flex: 1,
49
+ whiteSpace: isMobile ? 'normal' : 'nowrap',
50
+ }}
51
+ onClick={handleClick}>
52
+ {title}
53
+ {description}
54
+ </Typography>
55
+ </Box>
57
56
  );
58
57
  }
59
58
 
@@ -1,12 +1,13 @@
1
1
  import Badge from '@mui/material/Badge';
2
2
  import PropTypes from 'prop-types';
3
- import { useCallback, useEffect } from 'react';
3
+ import { useCallback, useEffect, useMemo } from 'react';
4
4
  import { IconButton } from '@mui/material';
5
5
  import { useSnackbar } from 'notistack';
6
6
  // eslint-disable-next-line import/no-extraneous-dependencies
7
7
  import NotificationsOutlinedIcon from '@arcblock/icons/lib/Notification';
8
8
  import { useCreation } from 'ahooks';
9
9
  import { EVENTS, WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
10
+ import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
10
11
  import { joinURL, withQuery } from 'ufo';
11
12
  import { useListenWsClient } from './ws';
12
13
  import NotificationSnackbar from '../Notifications/Snackbar';
@@ -27,6 +28,12 @@ export default function NotificationAddon({ session = {} }) {
27
28
  const userDid = useCreation(() => user?.did, [user]);
28
29
 
29
30
  const { enqueueSnackbar } = useSnackbar();
31
+ const browser = useBrowser();
32
+
33
+ // 在 ArcSphere 和 Wallet 端隐藏, 消息的 toast 提示,因为有 native 的通知
34
+ const hiddenNotificationToast = useMemo(() => {
35
+ return browser.arcSphere || browser.wallet;
36
+ }, [browser]);
30
37
 
31
38
  const serverVersion = useCreation(() => {
32
39
  return window.blocklet?.serverVersion;
@@ -51,10 +58,10 @@ export default function NotificationAddon({ session = {} }) {
51
58
 
52
59
  if (notificationReceiver === userDid) {
53
60
  setUnReadCount((x) => x + 1);
54
- // 显示通知, 如果是系统通知则不需要显示
61
+ // 显示通知, 如果是系统通知则不需要显示, 如果是移动端不需要显示
55
62
  // 兼容代码,如果 server 没有升级那么不需要提示
56
63
  const isCompatible = compareVersions(serverVersion, '1.16.42-beta-20250407');
57
- if (notification.source === 'component' && isCompatible) {
64
+ if (!hiddenNotificationToast && notification.source === 'component' && isCompatible) {
58
65
  const link = getNotificationLink(notification);
59
66
  const { severity, description } = notification || {};
60
67
  const disableAutoHide = ['error', 'warning'].includes(severity) || notification.sticky;
@@ -67,7 +74,7 @@ export default function NotificationAddon({ session = {} }) {
67
74
  }
68
75
  }
69
76
  },
70
- [userDid, setUnReadCount, enqueueSnackbar, serverVersion]
77
+ [userDid, setUnReadCount, enqueueSnackbar, serverVersion, hiddenNotificationToast]
71
78
  );
72
79
 
73
80
  const readListenCallback = useCallback(