Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fc5f954
Query entries from node
cafca Apr 9, 2021
f934b87
Use camelCase api and some clean up
cafca Apr 9, 2021
ae3446e
Split up p2panda-api
cafca Apr 9, 2021
0b338eb
Refactor p2panda-api
cafca Apr 9, 2021
fd3ebf3
Store nextEntryArgs after publish
cafca Apr 9, 2021
7083bf6
Restrict length of chat log
cafca Apr 9, 2021
44a1e6a
Use the full message fields format when creating entries
cafca Apr 10, 2021
117c8ff
Cleanup and docs
cafca Apr 14, 2021
d555ab0
Fix folder name of Chatlog component
adzialocha Apr 15, 2021
a3a6e1e
Remove unused dependency
adzialocha Apr 15, 2021
292331e
More cleanup
adzialocha Apr 15, 2021
c36bd1d
Merge branch 'main' into query-entries
adzialocha Apr 15, 2021
b79c652
Move variables into own file and use them in Instructions
adzialocha Apr 15, 2021
8e61f28
Fix disappearing messages by introducing author to react key
adzialocha Apr 15, 2021
bd438fd
Fix slicing of last 10 messages
adzialocha Apr 15, 2021
26d79cc
Introduce date in message schema
adzialocha Apr 15, 2021
400c09a
Fix typo
cafca Apr 16, 2021
afd3830
Don't wait for session to be ready
cafca Apr 16, 2021
8fe0c9a
Allow toggling message sync
cafca Apr 16, 2021
e9b593f
Add a title
adzialocha Apr 16, 2021
ab0a51c
Correct variable name in Instructions
adzialocha Apr 16, 2021
32f8ee8
Log created message fields
cafca Apr 17, 2021
f2ed259
Don't reencode key pair
cafca Apr 17, 2021
9c23a9a
Merge branch 'query-entries' of github.com:p2panda/beep-boop into que…
cafca Apr 17, 2021
0f4ddf2
Fix sorting entries by date
adzialocha Apr 17, 2021
6772745
Make log entry clickable, minor css changes, nicer hashes
adzialocha Apr 17, 2021
23ab8cb
Fix memory leak
cafca May 13, 2021
2dbb1d2
Surface only untagged message field values
cafca May 13, 2021
6473f49
Use untagged messagefields form
cafca May 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't wait for session to be ready
Now that key pair is no longer required for creating a session we don't
have to wait for it to be ready.
  • Loading branch information
cafca committed Apr 16, 2021
commit afd383084530e1d39c63bbc40dc487d1cb3d996a
32 changes: 7 additions & 25 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useCallback, useState } from 'react';
import React, { useEffect, useState } from 'react';
import p2panda from 'p2panda-js';

import { BambooLog } from '~/components/BambooLog';
Expand All @@ -18,10 +18,7 @@ const App = (): JSX.Element => {
const [entries, setEntries] = useState<EntryRecord[]>([]);
const [session, setSession] = useState<Session>(null);

const syncEntries = useCallback(async () => {
if (!session) {
return;
}
const syncEntries = async () => {
const unsortedEntries = await session.queryEntries(CHAT_SCHEMA);
setEntries(
unsortedEntries.sort((entryA, entryB) => {
Expand All @@ -33,8 +30,12 @@ const App = (): JSX.Element => {
);
}, [session]);

// Generate or load key pair on initial page load
useEffect(() => {
// Load incoming messages frequently
syncEntries();
window.setInterval(syncEntries, 5000);

// Generate or load key pair on initial page load
const asyncEffect = async () => {
const { KeyPair } = await p2panda;
let privateKey = window.localStorage.getItem('privateKey');
Expand All @@ -48,25 +49,6 @@ const App = (): JSX.Element => {
asyncEffect();
}, []);

// Establish session in the beginning
useEffect(() => {
setSession(new Session(ENDPOINT));
}, []);

// Refresh chat log when session is ready
useEffect(() => {
if (!session) {
return;
}

// Load incoming messages frequently
window.setInterval(() => {
syncEntries();
}, 5000);

syncEntries();
}, [session]);

// Publish entries and refresh chat log to get the new message in the log
const handlePublish = async (message: string) => {
await Instance.create(
Expand Down