nftychat-universe 1.3.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs.js CHANGED
@@ -12407,7 +12407,6 @@ function DmButton(props) {
12407
12407
  const [numberOfNotifications, setNumberOfNotifications] = React.useState(0);
12408
12408
  const mainUrl = "https://nftychat-staging.herokuapp.com"; // const mainUrl = "http://localhost:8080";
12409
12409
 
12410
- const [accessToken, setAccessToken] = React.useState(null);
12411
12410
  const [messageText, setMessageText] = React.useState("");
12412
12411
  const [popoverAnchor, setPopoverAnchor] = React.useState(null);
12413
12412
  const [displayName, setDisplayName] = React.useState(props.displayName);
@@ -12434,7 +12433,8 @@ function DmButton(props) {
12434
12433
  }
12435
12434
 
12436
12435
  resolveDisplayName();
12437
- }, [displayName, props.address]);
12436
+ }, [displayName, props.address]); // badge of unread messages
12437
+
12438
12438
  React.useEffect(() => {
12439
12439
  fetch(mainUrl + "/v1/unread_message_count?address=" + props.address, {
12440
12440
  method: "get"
@@ -12444,7 +12444,30 @@ function DmButton(props) {
12444
12444
  setNumberOfNotifications(data);
12445
12445
  console.log(data);
12446
12446
  });
12447
- }, [props.address]);
12447
+ }, [props.address]); // Checks validity of signature
12448
+
12449
+ async function checkSignature(tempAddress = wagmiAddress, signature = "0x") {
12450
+ const signatureUrl = `${mainUrl}/v1/authenticate?address=${tempAddress}&signature=${signature}&source=${window.location.hostname}`;
12451
+ const loginResponse = await fetch(signatureUrl);
12452
+
12453
+ if (!loginResponse.ok) {
12454
+ loginResponse.json().then(data => {
12455
+ _t.error(data["detail"]);
12456
+ });
12457
+ throw new Error(loginResponse.status);
12458
+ } //Set local storage with login vars
12459
+
12460
+
12461
+ const loginData = await loginResponse.json(); // If multisig wallet
12462
+
12463
+ if (loginData["status"] === "pending") {
12464
+ _t.error("Multisig not enabled");
12465
+ return;
12466
+ }
12467
+
12468
+ return loginData["token"];
12469
+ } // calls check signature and saves access token
12470
+
12448
12471
 
12449
12472
  async function getAccessToken() {
12450
12473
  let tempAccessToken = localStorage.getItem("token_" + wagmiAddress);
@@ -12489,6 +12512,8 @@ function DmButton(props) {
12489
12512
 
12490
12513
 
12491
12514
  React.useEffect(() => {
12515
+ console.log(popoverAnchor, wagmiAddress);
12516
+
12492
12517
  if (!!wagmiAddress && !!popoverAnchor) {
12493
12518
  getAccessToken();
12494
12519
  }
@@ -12532,29 +12557,6 @@ function DmButton(props) {
12532
12557
  });
12533
12558
  }
12534
12559
 
12535
- async function checkSignature(tempAddress = wagmiAddress, signature = "0x") {
12536
- const signatureUrl = `${mainUrl}/v1/authenticate?address=${tempAddress}&signature=${signature}&source=${window.location.hostname}`;
12537
- const loginResponse = await fetch(signatureUrl);
12538
-
12539
- if (!loginResponse.ok) {
12540
- loginResponse.json().then(data => {
12541
- _t.error(data["detail"]);
12542
- });
12543
- throw new Error(loginResponse.status);
12544
- } //Set local storage with login vars
12545
-
12546
-
12547
- const loginData = await loginResponse.json(); // If multisig wallet
12548
-
12549
- if (loginData["status"] === "pending") {
12550
- _t.error("Multisig not enabled");
12551
- return;
12552
- }
12553
-
12554
- setAccessToken(loginData["token"]);
12555
- return loginData["token"];
12556
- }
12557
-
12558
12560
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
12559
12561
  className: props.theme === "dark" ? "universal_button universal_button___dark" : "universal_button",
12560
12562
  children: [/*#__PURE__*/jsxRuntime.jsxs("button", {
package/dist/index.esm.js CHANGED
@@ -12380,7 +12380,6 @@ function DmButton(props) {
12380
12380
  const [numberOfNotifications, setNumberOfNotifications] = useState(0);
12381
12381
  const mainUrl = "https://nftychat-staging.herokuapp.com"; // const mainUrl = "http://localhost:8080";
12382
12382
 
12383
- const [accessToken, setAccessToken] = useState(null);
12384
12383
  const [messageText, setMessageText] = useState("");
12385
12384
  const [popoverAnchor, setPopoverAnchor] = useState(null);
12386
12385
  const [displayName, setDisplayName] = useState(props.displayName);
@@ -12407,7 +12406,8 @@ function DmButton(props) {
12407
12406
  }
12408
12407
 
12409
12408
  resolveDisplayName();
12410
- }, [displayName, props.address]);
12409
+ }, [displayName, props.address]); // badge of unread messages
12410
+
12411
12411
  useEffect(() => {
12412
12412
  fetch(mainUrl + "/v1/unread_message_count?address=" + props.address, {
12413
12413
  method: "get"
@@ -12417,7 +12417,30 @@ function DmButton(props) {
12417
12417
  setNumberOfNotifications(data);
12418
12418
  console.log(data);
12419
12419
  });
12420
- }, [props.address]);
12420
+ }, [props.address]); // Checks validity of signature
12421
+
12422
+ async function checkSignature(tempAddress = wagmiAddress, signature = "0x") {
12423
+ const signatureUrl = `${mainUrl}/v1/authenticate?address=${tempAddress}&signature=${signature}&source=${window.location.hostname}`;
12424
+ const loginResponse = await fetch(signatureUrl);
12425
+
12426
+ if (!loginResponse.ok) {
12427
+ loginResponse.json().then(data => {
12428
+ _t.error(data["detail"]);
12429
+ });
12430
+ throw new Error(loginResponse.status);
12431
+ } //Set local storage with login vars
12432
+
12433
+
12434
+ const loginData = await loginResponse.json(); // If multisig wallet
12435
+
12436
+ if (loginData["status"] === "pending") {
12437
+ _t.error("Multisig not enabled");
12438
+ return;
12439
+ }
12440
+
12441
+ return loginData["token"];
12442
+ } // calls check signature and saves access token
12443
+
12421
12444
 
12422
12445
  async function getAccessToken() {
12423
12446
  let tempAccessToken = localStorage.getItem("token_" + wagmiAddress);
@@ -12462,6 +12485,8 @@ function DmButton(props) {
12462
12485
 
12463
12486
 
12464
12487
  useEffect(() => {
12488
+ console.log(popoverAnchor, wagmiAddress);
12489
+
12465
12490
  if (!!wagmiAddress && !!popoverAnchor) {
12466
12491
  getAccessToken();
12467
12492
  }
@@ -12505,29 +12530,6 @@ function DmButton(props) {
12505
12530
  });
12506
12531
  }
12507
12532
 
12508
- async function checkSignature(tempAddress = wagmiAddress, signature = "0x") {
12509
- const signatureUrl = `${mainUrl}/v1/authenticate?address=${tempAddress}&signature=${signature}&source=${window.location.hostname}`;
12510
- const loginResponse = await fetch(signatureUrl);
12511
-
12512
- if (!loginResponse.ok) {
12513
- loginResponse.json().then(data => {
12514
- _t.error(data["detail"]);
12515
- });
12516
- throw new Error(loginResponse.status);
12517
- } //Set local storage with login vars
12518
-
12519
-
12520
- const loginData = await loginResponse.json(); // If multisig wallet
12521
-
12522
- if (loginData["status"] === "pending") {
12523
- _t.error("Multisig not enabled");
12524
- return;
12525
- }
12526
-
12527
- setAccessToken(loginData["token"]);
12528
- return loginData["token"];
12529
- }
12530
-
12531
12533
  return /*#__PURE__*/jsxs("div", {
12532
12534
  className: props.theme === "dark" ? "universal_button universal_button___dark" : "universal_button",
12533
12535
  children: [/*#__PURE__*/jsxs("button", {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/nftychat/nftychat-universe"
6
6
  },
7
- "version": "1.3.0",
7
+ "version": "1.3.2",
8
8
  "license": "MIT",
9
9
  "description": "nftychat plugins for your website",
10
10
  "author": "nftychat",