Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.
Prev Previous commit
Next Next commit
Sketch for using beep-boop with bookmark schema
  • Loading branch information
cafca committed Jan 25, 2022
commit d73eddcc64af1d3ff9aff84a2485327c2d0059de
11 changes: 7 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ const App = (): JSX.Element => {

const syncEntries = async () => {
const unsortedEntries = await session.queryEntries(CHAT_SCHEMA);

setEntries(
unsortedEntries.sort(({ message: messageA }, { message: messageB }) => {
return messageA.fields.date > messageB.fields.date ? 1 : -1;
unsortedEntries.sort(({ operation: opA }, { operation: opB }) => {
return opA.fields.created > opB.fields.created ? 1 : -1;
}),
);
};
Expand Down Expand Up @@ -57,10 +58,12 @@ const App = (): JSX.Element => {

// Publish entries and refresh chat log to get the new message in the log
const handlePublish = async (message: string) => {
const [url, title] = message.split(' ', 2);
await session.create(
{
message,
date: new Date().toISOString(),
url: url,
title: title,
created: new Date().toISOString(),
},
{ schema: CHAT_SCHEMA, session, keyPair },
);
Expand Down
8 changes: 4 additions & 4 deletions src/components/BambooLog/LogEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const formatMessage = (message: string): string => {
};

export const LogEntry = ({ entry }: Props): JSX.Element => {
const { message, entryHashBacklink, entryHashSkiplink } = entry;
const { operation, entryHashBacklink, entryHashSkiplink } = entry;
return (
<div className="flex-column">
<div className="entry-data flex-row">
Expand All @@ -28,10 +28,10 @@ export const LogEntry = ({ entry }: Props): JSX.Element => {
</div>
<div className="entry-content flex-row">
<div className="flex-column">
<b>{message.action}</b>
<b>{operation.action}</b>
<ul>
<li>Schema: {formatCheckHash(message.schema)}</li>
<li>Message: {formatMessage(message.fields.message)}</li>
<li>Schema: {formatCheckHash(operation.schema)}</li>
<li>Message: {formatMessage(operation.fields.url)}</li>
<li>BackLink: {formatCheckHash(entryHashBacklink)}</li>
<li>SkipLink: {formatCheckHash(entryHashSkiplink)}</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chatlog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Chatlog = ({
onClick={() => setDebugEntry(entry)}
>
<h3 className="message">
{formatAuthor(entry.encoded)}: {entry.message.fields.message}
{formatAuthor(entry.encoded)}: {entry.operation.fields.url} {entry.operation.fields.title}
</h3>
</div>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

export const ENDPOINT = 'http://localhost:2020';
export const CHAT_SCHEMA =
'0040cf94f6d605657e90c543b0c919070cdaaf7209c5e1ea58acb8f3568fa2114268dc9ac3bafe12af277d286fce7dc59b7c0c348973c4e9dacbe79485e56ac2a702';
'0020c65567ae37efea293e34a9c7d13f8f2bf23dbdc3b5c7b9ab46293111c48fc78b';