timqian commited on
Commit
e050f32
1 Parent(s): c2d4e9c

listen to parent msg

Browse files
asset-manifest.json CHANGED
@@ -1,15 +1,15 @@
1
  {
2
  "files": {
3
  "main.css": "/static/css/main.5173ff82.css",
4
- "main.js": "/static/js/main.f9e86fbe.js",
5
  "static/js/787.0bfccc2a.chunk.js": "/static/js/787.0bfccc2a.chunk.js",
6
  "index.html": "/index.html",
7
  "main.5173ff82.css.map": "/static/css/main.5173ff82.css.map",
8
- "main.f9e86fbe.js.map": "/static/js/main.f9e86fbe.js.map",
9
  "787.0bfccc2a.chunk.js.map": "/static/js/787.0bfccc2a.chunk.js.map"
10
  },
11
  "entrypoints": [
12
  "static/css/main.5173ff82.css",
13
- "static/js/main.f9e86fbe.js"
14
  ]
15
  }
 
1
  {
2
  "files": {
3
  "main.css": "/static/css/main.5173ff82.css",
4
+ "main.js": "/static/js/main.aa7e8056.js",
5
  "static/js/787.0bfccc2a.chunk.js": "/static/js/787.0bfccc2a.chunk.js",
6
  "index.html": "/index.html",
7
  "main.5173ff82.css.map": "/static/css/main.5173ff82.css.map",
8
+ "main.aa7e8056.js.map": "/static/js/main.aa7e8056.js.map",
9
  "787.0bfccc2a.chunk.js.map": "/static/js/787.0bfccc2a.chunk.js.map"
10
  },
11
  "entrypoints": [
12
  "static/css/main.5173ff82.css",
13
+ "static/js/main.aa7e8056.js"
14
  ]
15
  }
index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="View the like history of a project on huggingface"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Like History</title><script defer="defer" src="/static/js/main.f9e86fbe.js"></script><link href="/static/css/main.5173ff82.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
 
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="View the like history of a project on huggingface"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Like History</title><script defer="defer" src="/static/js/main.aa7e8056.js"></script><link href="/static/css/main.5173ff82.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
src/App.js CHANGED
@@ -27,9 +27,7 @@ function transformLikesData(likesData) {
27
 
28
  function getProjectsFromHash() {
29
  let hash = window.location.hash;
30
- if (!hash) {
31
- hash = window.parent.location.hash;
32
- }
33
  const projects = hash.replace("#", "").split('&').filter(project => project !== '');
34
  return projects;
35
  }
@@ -142,6 +140,27 @@ function App() {
142
  setHash()
143
  }, [datasets])
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  useEffect(() => {
146
  const projects = getProjectsFromHash();
147
  if (projects.length <= 0) return;
@@ -163,7 +182,6 @@ function App() {
163
 
164
  getLikeHistoryAndDisplay()
165
 
166
-
167
  }, [])
168
 
169
  return (
 
27
 
28
  function getProjectsFromHash() {
29
  let hash = window.location.hash;
30
+
 
 
31
  const projects = hash.replace("#", "").split('&').filter(project => project !== '');
32
  return projects;
33
  }
 
140
  setHash()
141
  }, [datasets])
142
 
143
+ useEffect(() => {
144
+ function handleReceiveMessage(event) {
145
+ // You might want to check event.origin here for security if needed
146
+ // and ensure that event.data contains the properties you expect
147
+ if (event.data && typeof event.data === 'object' && 'hash' in event.data) {
148
+ // Update the hash of the parent window's URL
149
+ window.location.hash = event.data.hash;
150
+ console.log('hash')
151
+ console.log(window.location.hash)
152
+ }
153
+ }
154
+
155
+ // Add event listener for 'message' events
156
+ window.addEventListener('message', handleReceiveMessage);
157
+
158
+ // Clean up the event listener on component unmount
159
+ return () => {
160
+ window.removeEventListener('message', handleReceiveMessage);
161
+ };
162
+ }, []);
163
+
164
  useEffect(() => {
165
  const projects = getProjectsFromHash();
166
  if (projects.length <= 0) return;
 
182
 
183
  getLikeHistoryAndDisplay()
184
 
 
185
  }, [])
186
 
187
  return (
static/js/main.aa7e8056.js ADDED
The diff for this file is too large to render. See raw diff
 
static/js/main.aa7e8056.js.LICENSE.txt ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
2
+
3
+ /**
4
+ * @license React
5
+ * react-dom.production.min.js
6
+ *
7
+ * Copyright (c) Facebook, Inc. and its affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+
13
+ /**
14
+ * @license React
15
+ * react-jsx-runtime.production.min.js
16
+ *
17
+ * Copyright (c) Facebook, Inc. and its affiliates.
18
+ *
19
+ * This source code is licensed under the MIT license found in the
20
+ * LICENSE file in the root directory of this source tree.
21
+ */
22
+
23
+ /**
24
+ * @license React
25
+ * react.production.min.js
26
+ *
27
+ * Copyright (c) Facebook, Inc. and its affiliates.
28
+ *
29
+ * This source code is licensed under the MIT license found in the
30
+ * LICENSE file in the root directory of this source tree.
31
+ */
32
+
33
+ /**
34
+ * @license React
35
+ * scheduler.production.min.js
36
+ *
37
+ * Copyright (c) Facebook, Inc. and its affiliates.
38
+ *
39
+ * This source code is licensed under the MIT license found in the
40
+ * LICENSE file in the root directory of this source tree.
41
+ */
static/js/main.aa7e8056.js.map ADDED
The diff for this file is too large to render. See raw diff
 
static/js/main.e65f6e7b.js.map CHANGED
The diff for this file is too large to render. See raw diff