New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@solarpunkltd/comment-system-ui

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solarpunkltd/comment-system-ui - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

dist/components/icons/AvatarMonogram/AvatarMonogram.js

25

dist/components/swarm-comment-system/swarm-comment-list/swarm-comment-list.js

@@ -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;

53

dist/components/swarm-comment-system/SwarmCommentSystem.js
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": {

}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc