@solarpunkltd/comment-system-ui
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,4 +0,21 @@ | ||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
export default function SwarmCommentList({ comments }) { | ||
return (_jsx("div", { className: "swarm-comment-system-comment-list", children: comments.map(({ user, data, timestamp }, index) => (_jsxs("div", { children: [_jsxs("p", { children: [_jsx("strong", { children: user }), " on ", new Date(timestamp).toDateString()] }), _jsx("p", { children: data })] }, index))) })); | ||
} | ||
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; | ||
// import "./swarm-comment-list.scss"; | ||
import SwarmComment from "./swarm-comment/swarm-comment"; | ||
const SwarmCommentList = ({ comments, loading, }) => { | ||
if (!comments || comments.length === 0) { | ||
return (_jsx("div", { className: "swarm-comment-system-comment-list__no-comments", style: { | ||
alignContent: "center", | ||
fontFamily: "Public Sans", | ||
fontSize: "16px", | ||
lineHeight: "20px", | ||
letterSpacing: "0.5%", | ||
color: "#333333", | ||
}, children: loading ? (_jsx("p", { children: "Loading comments..." })) : (_jsxs(_Fragment, { children: [_jsx("p", { children: "There are no comments yet." }), _jsx("p", { children: "Start the conversation!\"" })] })) })); | ||
} | ||
return (_jsx("div", { className: "swarm-comment-system-comment-list", style: { | ||
textAlign: "center", | ||
flexGrow: "1", | ||
overflow: "scroll", | ||
}, children: comments.map((msg, ix) => (_jsx(SwarmComment, { data: msg.data, user: msg.user, timestamp: msg.timestamp }, ix))) })); | ||
}; | ||
export default SwarmCommentList; |
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
import { readComments, writeComment } from 'solarpunk-comment-system'; | ||
import { readComments, writeComment, } from "@solarpunkltd/comment-system"; | ||
import SwarmCommentList from "./swarm-comment-list/swarm-comment-list"; | ||
import { useEffect, useState } from "react"; | ||
import SwarmCommentForm from "./swarm-comment-form/swarm-comment-form"; | ||
import SwarmCommentInput from "../swarm-comment-input/swarm-comment-input"; | ||
import { Bee } from "@ethersphere/bee-js"; | ||
export function SwarmCommentSystem(props) { | ||
const { stamp, topic, beeApiUrl, privateKey, signer } = props; | ||
export const SwarmCommentSystem = ({ stamp, topic, beeApiUrl, signer, username, }) => { | ||
const bee = new Bee(beeApiUrl); | ||
@@ -13,16 +12,14 @@ const topicHex = bee.makeFeedTopic(topic); | ||
const [loading, setLoading] = useState(true); | ||
const [formLoading, setFormLoading] = useState(false); | ||
const [error, setError] = useState(null); | ||
/** If the room already exists, it will load the comments, | ||
* otherwise, it will create the room */ | ||
async function init() { | ||
const isRetrievable = await loadComments(); | ||
if (!isRetrievable) { | ||
await createFeed(); | ||
} | ||
} | ||
useEffect(() => { | ||
init(); | ||
}, []); | ||
/** If the room already exists, it will load the messages, | ||
* otherwise, it will create the room */ | ||
async function init() { | ||
const retrievable = await bee.isFeedRetrievable('sequence', signer.address, topicHex); | ||
if (retrievable) | ||
loadComments(); | ||
else | ||
createFeed(); | ||
} | ||
// Will create a feed, with topic (room-name) | ||
@@ -32,3 +29,3 @@ async function createFeed() { | ||
console.info("Feed does not exist. Creating feed..."); | ||
const feedReference = await bee.createFeedManifest(stamp, 'sequence', topicHex, signer.address); | ||
const feedReference = await bee.createFeedManifest(stamp, "sequence", topicHex, signer.address); | ||
console.info(`Created feed with reference ${feedReference.reference}`); | ||
@@ -40,2 +37,3 @@ setComments([]); | ||
console.error("feed gen error", e); | ||
setError(false); | ||
} | ||
@@ -45,2 +43,3 @@ } | ||
const loadComments = async () => { | ||
let isRetrievable = false; | ||
try { | ||
@@ -54,9 +53,10 @@ setLoading(true); | ||
approvedFeedAddress: signer.address, | ||
privateKey | ||
}); | ||
console.log("readed comments: ", comments); | ||
console.log("read comments: ", comments); | ||
setComments(comments); | ||
isRetrievable = true; | ||
} | ||
catch (error) { | ||
console.error(error); | ||
setError(error); | ||
} | ||
@@ -66,7 +66,6 @@ finally { | ||
} | ||
return isRetrievable; | ||
}; | ||
// Sends a message to the room | ||
const sendComment = async (comment) => { | ||
try { | ||
setFormLoading(true); | ||
const newComment = await writeComment(comment, { | ||
@@ -77,3 +76,2 @@ stamp, | ||
beeApiUrl, | ||
privateKey | ||
}); | ||
@@ -83,6 +81,3 @@ if (!newComment) | ||
console.log("Write result ", newComment); | ||
setComments([ | ||
...comments, | ||
newComment, | ||
]); | ||
setComments([...comments, newComment]); | ||
} | ||
@@ -93,13 +88,7 @@ catch (error) { | ||
} | ||
finally { | ||
setFormLoading(false); | ||
} | ||
}; | ||
if (!comments) { | ||
return _jsx("div", { children: "Loading comments..." }); | ||
} | ||
if (error) { | ||
return (_jsx("div", { className: "swarm-comment-system-wrapper", children: "Error loading comments" })); | ||
} | ||
return (_jsxs("div", { className: "swarm-comment-system-wrapper", children: [_jsx(SwarmCommentForm, { onSubmit: sendComment, loading: loading || formLoading }), _jsx(SwarmCommentList, { comments: comments })] })); | ||
} | ||
return (_jsxs("div", { className: "swarm-comment-system-wrapper", children: [_jsx(SwarmCommentList, { comments: comments, loading: loading }), _jsx(SwarmCommentInput, { username: username, onSubmit: sendComment })] })); | ||
}; |
{ | ||
"name": "@solarpunkltd/comment-system-ui", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"type": "module", | ||
@@ -18,6 +18,6 @@ "main": "./dist/index.js", | ||
"@ethersphere/bee-js": "^6.4.1", | ||
"solarpunk-comment-system": "1.1.0", | ||
"ethers": "^6.8.0", | ||
"@solarpunkltd/comment-system": "^1.1.1", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1" | ||
"react-dom": "^18.3.1", | ||
"vite-plugin-node-polyfills": "^0.22.0" | ||
}, | ||
@@ -31,8 +31,10 @@ "devDependencies": { | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"@vitejs/plugin-react": "^4.3.1", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.3", | ||
"ethers": "^6.8.0", | ||
"sass": "^1.69.5", | ||
"typescript": "^5.0.2" | ||
"ethers": "^6.13.3", | ||
"sass": "^1.77.8", | ||
"typescript": "^5.0.2", | ||
"vite": "^5.4.8" | ||
}, | ||
@@ -43,2 +45,2 @@ "peerDependencies": { | ||
} | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15292
11
282
14
1
+ Added@esbuild/aix-ppc64@0.21.5(transitive)
+ Added@esbuild/android-arm@0.21.5(transitive)
+ Added@esbuild/android-arm64@0.21.5(transitive)
+ Added@esbuild/android-x64@0.21.5(transitive)
+ Added@esbuild/darwin-arm64@0.21.5(transitive)
+ Added@esbuild/darwin-x64@0.21.5(transitive)
+ Added@esbuild/freebsd-arm64@0.21.5(transitive)
+ Added@esbuild/freebsd-x64@0.21.5(transitive)
+ Added@esbuild/linux-arm@0.21.5(transitive)
+ Added@esbuild/linux-arm64@0.21.5(transitive)
+ Added@esbuild/linux-ia32@0.21.5(transitive)
+ Added@esbuild/linux-loong64@0.21.5(transitive)
+ Added@esbuild/linux-mips64el@0.21.5(transitive)
+ Added@esbuild/linux-ppc64@0.21.5(transitive)
+ Added@esbuild/linux-riscv64@0.21.5(transitive)
+ Added@esbuild/linux-s390x@0.21.5(transitive)
+ Added@esbuild/linux-x64@0.21.5(transitive)
+ Added@esbuild/netbsd-x64@0.21.5(transitive)
+ Added@esbuild/openbsd-x64@0.21.5(transitive)
+ Added@esbuild/sunos-x64@0.21.5(transitive)
+ Added@esbuild/win32-arm64@0.21.5(transitive)
+ Added@esbuild/win32-ia32@0.21.5(transitive)
+ Added@esbuild/win32-x64@0.21.5(transitive)
+ Added@ethersphere/bee-js@8.3.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@rollup/plugin-inject@5.0.5(transitive)
+ Added@rollup/pluginutils@5.1.4(transitive)
+ Added@rollup/rollup-android-arm-eabi@4.32.0(transitive)
+ Added@rollup/rollup-android-arm64@4.32.0(transitive)
+ Added@rollup/rollup-darwin-arm64@4.32.0(transitive)
+ Added@rollup/rollup-darwin-x64@4.32.0(transitive)
+ Added@rollup/rollup-freebsd-arm64@4.32.0(transitive)
+ Added@rollup/rollup-freebsd-x64@4.32.0(transitive)
+ Added@rollup/rollup-linux-arm-gnueabihf@4.32.0(transitive)
+ Added@rollup/rollup-linux-arm-musleabihf@4.32.0(transitive)
+ Added@rollup/rollup-linux-arm64-gnu@4.32.0(transitive)
+ Added@rollup/rollup-linux-arm64-musl@4.32.0(transitive)
+ Added@rollup/rollup-linux-loongarch64-gnu@4.32.0(transitive)
+ Added@rollup/rollup-linux-powerpc64le-gnu@4.32.0(transitive)
+ Added@rollup/rollup-linux-riscv64-gnu@4.32.0(transitive)
+ Added@rollup/rollup-linux-s390x-gnu@4.32.0(transitive)
+ Added@rollup/rollup-linux-x64-gnu@4.32.0(transitive)
+ Added@rollup/rollup-linux-x64-musl@4.32.0(transitive)
+ Added@rollup/rollup-win32-arm64-msvc@4.32.0(transitive)
+ Added@rollup/rollup-win32-ia32-msvc@4.32.0(transitive)
+ Added@rollup/rollup-win32-x64-msvc@4.32.0(transitive)
+ Added@solarpunkltd/comment-system@1.3.0(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Addedasn1.js@4.10.1(transitive)
+ Addedassert@2.1.0(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbn.js@5.2.1(transitive)
+ Addedbrowser-resolve@2.0.0(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbrowserify-cipher@1.0.1(transitive)
+ Addedbrowserify-des@1.0.2(transitive)
+ Addedbrowserify-rsa@4.1.1(transitive)
+ Addedbrowserify-sign@4.2.3(transitive)
+ Addedbrowserify-zlib@0.2.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedbuiltin-status-codes@3.0.0(transitive)
+ Addedcafe-utility@21.5.023.12.0(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedcipher-base@1.0.6(transitive)
+ Addedconsole-browserify@1.2.0(transitive)
+ Addedconstants-browserify@1.0.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcreate-ecdh@4.0.4(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addedcreate-require@1.1.1(transitive)
+ Addedcrypto-browserify@3.12.1(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddes.js@1.1.0(transitive)
+ Addeddiffie-hellman@5.0.3(transitive)
+ Addeddomain-browser@4.22.0(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedesbuild@0.21.5(transitive)
+ Addedestree-walker@2.0.2(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedfor-each@0.3.4(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhash-base@3.0.5(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttps-browserify@1.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-core-module@2.16.1(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-nan@1.3.2(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisomorphic-timers-promises@1.0.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedmagic-string@0.30.17(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedmiller-rabin@4.0.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addednanoid@3.3.8(transitive)
+ Addednock@13.5.6(transitive)
+ Addednode-stdlib-browser@1.3.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-is@1.1.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.7(transitive)
+ Addedos-browserify@0.3.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpako@1.0.11(transitive)
+ Addedparse-asn1@5.1.7(transitive)
+ Addedpath-browserify@1.0.1(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpicomatch@4.0.2(transitive)
+ Addedpkg-dir@5.0.0(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedpostcss@8.5.1(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedpropagate@2.0.1(transitive)
+ Addedpublic-encrypt@4.0.3(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.14.0(transitive)
+ Addedquerystring-es3@0.2.1(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedrandomfill@1.0.4(transitive)
+ Addedreadable-stream@2.3.83.6.2(transitive)
+ Addedresolve@1.22.10(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedrollup@4.32.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedsource-map-js@1.2.1(transitive)
+ Addedstream-browserify@3.0.0(transitive)
+ Addedstream-http@3.2.0(transitive)
+ Addedstring_decoder@1.1.11.3.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtimers-browserify@2.0.12(transitive)
+ Addedtty-browserify@0.0.1(transitive)
+ Addedurl@0.11.4(transitive)
+ Addedutil@0.12.5(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@9.0.1(transitive)
+ Addedvite@5.4.14(transitive)
+ Addedvite-plugin-node-polyfills@0.22.0(transitive)
+ Addedvm-browserify@1.1.2(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedethers@^6.8.0
- Removedsolarpunk-comment-system@1.1.0