@ludo.ninja/components 2.1.24 → 2.1.27

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.
@@ -66,6 +66,11 @@ const Subscription = () => {
66
66
  user: state.user,
67
67
  }));
68
68
  const userId = user?.userId || "";
69
+ const [readNotification] = api_1.notificationsSchema.useReadNotificationMutation({
70
+ context: {
71
+ uri: api_1.hosts.notificationsHost,
72
+ },
73
+ });
69
74
  (0, client_1.useSubscription)(api_1.notificationsSchema.OnNotificationDocument, {
70
75
  variables: { authToken, notificationTypes: [api_1.notificationsSchema.INotificationType.Push] },
71
76
  onData: (options) => {
@@ -131,6 +136,7 @@ const Subscription = () => {
131
136
  },
132
137
  });
133
138
  }
139
+ readNotification({ variables: { notificationId: notification.notificationId } });
134
140
  }
135
141
  },
136
142
  });
@@ -139,6 +145,16 @@ const Subscription = () => {
139
145
  const SubscriberNotification = () => {
140
146
  const isSignedIn = (0, store_1.useUserStore)((state) => state.isSignedIn);
141
147
  const key = isSignedIn ? "all includes" : "only common";
142
- return ((0, jsx_runtime_1.jsx)(NoSSR_1.default, { children: (0, jsx_runtime_1.jsx)(Subscription, {}, key) }));
148
+ const [isWindowVisible, setIsWindowVisible] = (0, react_1.useState)(true);
149
+ (0, react_1.useEffect)(() => {
150
+ const changeVisibility = () => {
151
+ setIsWindowVisible(!document.hidden);
152
+ };
153
+ document.addEventListener("visibilitychange", changeVisibility);
154
+ return () => {
155
+ document.removeEventListener("visibilitychange", changeVisibility);
156
+ };
157
+ }, []);
158
+ return ((0, jsx_runtime_1.jsx)(NoSSR_1.default, { children: isWindowVisible && (0, jsx_runtime_1.jsx)(Subscription, {}, key) }));
143
159
  };
144
160
  exports.SubscriberNotification = SubscriberNotification;
@@ -1,2 +1,2 @@
1
- import { AppProps } from 'next/app';
2
- export declare function useApollo(pageProps: AppProps['pageProps']): import("@apollo/client").ApolloClient<import("@apollo/client").NormalizedCacheObject>;
1
+ import { AppProps } from "next/app";
2
+ export declare function useApollo(pageProps: AppProps["pageProps"]): import("@apollo/client").ApolloClient<import("@apollo/client").NormalizedCacheObject>;
@@ -5,8 +5,20 @@ const react_1 = require("react");
5
5
  const graphql_1 = require("../../api/graphql");
6
6
  const api_1 = require("@ludo.ninja/api");
7
7
  const env_1 = require("../../store/env");
8
+ const nookies_1 = require("nookies");
9
+ const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
8
10
  function useApollo(pageProps) {
9
- const NEXT_PUBLIC_ENV_DOMAIN = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_DOMAIN);
11
+ const { NEXT_PUBLIC_ENV_VALUE, NEXT_PUBLIC_ENV_DOMAIN } = (0, env_1.useEnvStore)((state) => ({
12
+ NEXT_PUBLIC_ENV_VALUE: state.NEXT_PUBLIC_ENV_VALUE,
13
+ NEXT_PUBLIC_ENV_DOMAIN: state.NEXT_PUBLIC_ENV_DOMAIN,
14
+ }));
10
15
  const state = pageProps[graphql_1.APOLLO_STATE_PROP_NAME];
11
- return (0, react_1.useMemo)(() => api_1.graphqlConfig.initializeApollo(state, NEXT_PUBLIC_ENV_DOMAIN), [state]);
16
+ return (0, react_1.useMemo)(() => api_1.graphqlConfig.createErrorAuthInterceptor(api_1.graphqlConfig.initializeApollo(state, NEXT_PUBLIC_ENV_DOMAIN), () => {
17
+ api_1.authCookies.destroyCookies(NEXT_PUBLIC_ENV_DOMAIN);
18
+ (0, nookies_1.destroyCookie)(null, 'authMultiversXWallet', {
19
+ path: '/',
20
+ domain: NEXT_PUBLIC_ENV_DOMAIN,
21
+ });
22
+ window.location.replace(`${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["welcome"]}?alertError=authServerError`);
23
+ }), [state]);
12
24
  }
@@ -25,9 +25,9 @@ exports.useUiStore = (0, traditional_1.createWithEqualityFn)()((setState) => ({
25
25
  //notifications
26
26
  notifications: [],
27
27
  addNotification: async (content) => {
28
- if (process.env.NODE_ENV === 'development') {
29
- return;
30
- }
28
+ // if (process.env.NODE_ENV === 'development') {
29
+ // return;
30
+ // }
31
31
  let isOpenNotification;
32
32
  try {
33
33
  const response = (await (0, utils_1.sendEventToExtension)(utils_1.eventsTypes.pingVersion));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.1.24",
3
+ "version": "2.1.27",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",