Skip to content

Commit 9c0a603

Browse files
author
Julien Bouquillon
committed
fix: various
1 parent ed3258d commit 9c0a603

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

example/src/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import { OrbitProvider, useOrbitDb } from "../../src";
66

77
window.LOG = "*";
88

9-
const ORBIT_DB_EVENTS =
10-
"/orbitdb/zdpuB2cZqW3mNmAM1tZ6mNPpcw6bSdNKNgPw4ppqJpnjS8Teg/react-ortbitdb-eventlog";
9+
const ORBIT_DB_EVENTS = "react-ortbitdb-eventlog";
10+
//"/orbitdb/zdpuB2cZqW3mNmAM1tZ6mNPpcw6bSdNKNgPw4ppqJpnjS8Teg/react-ortbitdb-eventlog";
1111

12-
const ORBIT_DB_DOCS =
13-
"/orbitdb/zdpuAknUxcYsKArW2d8KtBhwyLfkmADo4wpwmC8ReKy3Q5pDR/react-ortbitdb-docstore";
12+
const ORBIT_DB_DOCS = "react-ortbitdb-docstore";
13+
//"/orbitdb/zdpuAknUxcYsKArW2d8KtBhwyLfkmADo4wpwmC8ReKy3Q5pDR/react-ortbitdb-docstore";
1414

15-
const ORBIT_DB_KEYVALUE =
16-
"/orbitdb/zdpuAod4qh5m3SmjuSVtLUEspqp1yCQABWm1iEdSPFDQ5mUkU/react-ortbitdb-keyvalue";
15+
const ORBIT_DB_KEYVALUE = "react-ortbitdb-keyvalue";
16+
//"/orbitdb/zdpuAod4qh5m3SmjuSVtLUEspqp1yCQABWm1iEdSPFDQ5mUkU/react-ortbitdb-keyvalue";
1717

18-
const ORBIT_DB_COUNTER =
19-
"/orbitdb/zdpuAzbF3ZzhMsbtw4vkKoP1BEcH1CbgE1fRMUuykQdcbHe7X/react-ortbitdb-counter";
18+
const ORBIT_DB_COUNTER = "react-ortbitdb-counter";
19+
//"/orbitdb/zdpuAzbF3ZzhMsbtw4vkKoP1BEcH1CbgE1fRMUuykQdcbHe7X/react-ortbitdb-counter";
2020

2121
const Intro = () => (
2222
<div className="jumbotron">
@@ -312,10 +312,10 @@ const CounterDemo = () => {
312312
return (
313313
<div>
314314
<p style={{ fontSize: "0.8em" }}>
315-
{(value && `Connected to ${ORBIT_DB_COUNTER}`) ||
315+
{(value !== undefined && `Connected to ${ORBIT_DB_COUNTER}`) ||
316316
`Connecting to ${ORBIT_DB_COUNTER}...`}
317317
</p>
318-
{value && (
318+
{value !== undefined && (
319319
<h1>
320320
<span
321321
className="badge badge-primary"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"clean": "rm -rf ./dist",
5050
"clean:demo": "rm -rf ./example/dist",
5151
"start": "parcel watch ./src/index.js --out-dir ./dist",
52-
"start:demo": "parcel ./example/src/index.html --out-dir ./example/dist",
52+
"start:demo": "parcel serve ./example/src/index.html --out-dir ./example/dist",
5353
"build": "yarn run build:browser && yarn run build:cjs && yarn run build:esm",
5454
"build:browser": "parcel build ./src/index.js --global react-orbitdb",
5555
"build:cjs": "BABEL_ENV=cjs babel src --out-dir cjs",

src/ipfs-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ const DEFAULT_IPFS_CONFIG = {
99
preload: {
1010
enabled: false,
1111
},
12-
repo: "./some-repo",
12+
repo: "./example",
1313
EXPERIMENTAL: { pubsub: true },
1414
config: {
1515
Bootstrap: [
16-
// "/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
16+
//"/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
1717
// "/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3",
1818
// "/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
1919
// "/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",

src/useOrbitDb.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,26 @@ const useOrbitDb = (address, options = {}) => {
2727
if (!address) return;
2828

2929
const createDb = async () => {
30+
logger.debug("orbit.create", address);
31+
3032
const allOptions = {
3133
indexBy: "id",
32-
create: false,
34+
create: true, // doesnt really work ?
3335
type: "keyvalue",
3436
overwrite: false,
3537
...options,
36-
// options.public controls write access
38+
// // options.public controls write access
3739
...(options.create && options.public
3840
? publicWrite(orbit)
3941
: publicRead(orbit)),
4042
};
41-
logger.debug("orbit.open", address, allOptions);
42-
const db = await orbit.open(address, allOptions);
43+
const dbAddress = await orbit.determineAddress(
44+
address,
45+
allOptions.type,
46+
allOptions
47+
);
48+
logger.debug("orbit.open", dbAddress, allOptions);
49+
const db = await orbit.open(dbAddress, allOptions);
4350
logger.debug("orbitdb.opened", db.address.toString());
4451
const refreshDb = async () => {
4552
await db.load();
@@ -75,6 +82,11 @@ const useOrbitDb = (address, options = {}) => {
7582
logger.debug("db.events.write", address.toString());
7683
refreshDb();
7784
});
85+
86+
db.events.on("error", (err) => {
87+
logger.debug("db.events.error", err);
88+
refreshDb();
89+
});
7890
await refreshDb();
7991
};
8092
if (orbit) {

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,9 +2800,9 @@ caniuse-api@^3.0.0:
28002800
lodash.uniq "^4.5.0"
28012801

28022802
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001043:
2803-
version "1.0.30001078"
2804-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001078.tgz#e1b6e2ae327b6a1ec11f65ec7a0dde1e7093074c"
2805-
integrity sha512-sF12qXe9VMm32IEf/+NDvmTpwJaaU7N1igpiH2FdI4DyABJSsOqG3ZAcFvszLkoLoo1y6VJLMYivukUAxaMASw==
2803+
version "1.0.30001344"
2804+
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001344.tgz"
2805+
integrity sha512-0ZFjnlCaXNOAYcV7i+TtdKBp0L/3XEU2MF/x6Du1lrh+SRX4IfzIVL4HNJg5pB2PmFb8rszIGyOvsZnqqRoc2g==
28062806

28072807
capture-exit@^2.0.0:
28082808
version "2.0.0"

0 commit comments

Comments
 (0)