Skip to content

Commit 4546dca

Browse files
committed
new message fixes
1 parent faa6d49 commit 4546dca

File tree

6 files changed

+15
-21
lines changed

6 files changed

+15
-21
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"keywords": [
99
"arweave",
1010
"ao",
11-
"betteridea",
1211
"ide",
12+
"betteridea",
1313
"codecell"
1414
],
1515
"private": false,
@@ -40,11 +40,11 @@
4040
"prepare": "npm run build"
4141
},
4242
"dependencies": {
43-
"@permaweb/aoconnect": "^0.0.55",
4443
"react": "^18.2.0",
4544
"react-dom": "^18.2.0"
4645
},
4746
"devDependencies": {
47+
"@permaweb/aoconnect": "^0.0.55",
4848
"@rollup/plugin-typescript": "^11.1.6",
4949
"@types/node": "^20.12.12",
5050
"@types/react": "^18.2.66",
@@ -61,4 +61,4 @@
6161
"vite": "^5.2.0",
6262
"vite-plugin-dts": "^3.9.1"
6363
}
64-
}
64+
}

src/components/codecell.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ async function getResults(process: string, cursor = "") {
77
const r = await ao.results({
88
process,
99
from: cursor,
10-
sort: "DESC",
11-
limit: 10,
10+
sort: "ASC",
11+
limit: 999,
1212
})
1313

1414
if (r.edges.length > 0) {
@@ -77,11 +77,11 @@ export default function CodeCell({ cellId,
7777
async function fetchNewInboxMsg() {
7878
const localCursor = sessionStorage.getItem("cursor") || ""
7979
const r = await getResults(sessionStorage.getItem("cell-ao-id") as string, localCursor)
80-
console.log(r.cursor)
81-
if (!localCursor) // if ran for first time, dont fetch old stuff
80+
if (!localCursor) // if ran for first time, set cursor and return
8281
return sessionStorage.setItem("cursor", r.cursor)
8382

8483
if (r.cursor != sessionStorage.getItem("cursor")) {
84+
console.log(r.cursor)
8585
sessionStorage.setItem("cursor", r.cursor)
8686
if (r.results.length > 0) {
8787
// console.log(r.results)

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import CodeCell from "./components/codecell"
2-
import runCell from "./lib/runCell"
32
import getInbox from "./lib/getInbox"
43
import setCellCode from "./lib/setCellCode"
54

6-
export { CodeCell, runCell, setCellCode, getInbox }
5+
export { CodeCell, setCellCode, getInbox }

src/lib/getInbox.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ export default function getInbox(cellId: string, devMode = false) {
66
const host = devMode ? "*" : "https://ide.betteridea.dev";
77
iframe.contentWindow.postMessage({ action: "get_inbox" }, host);
88
}
9-
10-
119
}

src/main.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom/client'
33
import CodeCell from "./components/codecell"
4-
import runCell from "./lib/runCell"
54
import getInbox from './lib/getInbox'
65
import setCellCode from './lib/setCellCode'
7-
import "./styles/index.css"
86

97
function onInput(e: string) {
108
console.log(e)
@@ -15,9 +13,6 @@ function onInput(e: string) {
1513
ReactDOM.createRoot(document.getElementById('root')!).render(
1614
<React.StrictMode>
1715
<div style={{ padding: "10px", backgroundColor: "black", height: "100vh" }}>
18-
{/* <button onClick={() => {
19-
runCell("1", true)
20-
}}>run</button> */}
2116
<button onClick={() => {
2217
getInbox("1", true)
2318
}}>get inbox</button>
@@ -26,7 +21,13 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
2621

2722
<CodeCell appName="test-cell" cellId="1" devMode
2823
onAOProcess={(p) => console.log("got pid from webview", p)}
29-
onNewMessage={(m) => console.log("got new message in process", m)}
24+
onNewMessage={(message) => {
25+
message.forEach((m) => {
26+
if (m.Output)
27+
if (m.Output.print)
28+
console.log(m.Output.data)
29+
})
30+
}}
3031
onInbox={(i) => console.log("got inbox", i)}
3132
/>
3233
</div>

src/styles/index.css

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)