cameroncowden / datchatapp

0 stars 0 forks source link

Fails to "fork" self into new client chat dat #1

Open cameroncowden opened 6 years ago

cameroncowden commented 6 years ago

https://github.com/cameroncowden/datchatapp/blob/f8d08f3788429f8f56f84c5b3ba7f4b7043bf205/app.js#L271

The basic idea is: To join a chatroom, the user supplies a nickname and clicks the join button on the host dat, which then creates a new dat on the user's machine (that the user can write to), and it should update nick.txt with their chosen name, and include additional code to periodically updated the addresses.json from the host dat's (so that other users who join are added to existing clients).

But for some reason right now it's throwing errors when trying to create and initialize the new dat. Appears to be related to async and await.

pfrazee commented 6 years ago

@cameroncowden what's the error?

cameroncowden commented 6 years ago

@pfrazee Shite - my bad, didn't have it showing the error correctly. image

I think it's related to my setup here - const chatclient = await DatArchive.create(); var chatclientinfo = await chatclient.getInfo();

and later in the same function await chatclient.writeFile('nick.txt', user);

it's not defined? I thought awaits would queue?

pfrazee commented 6 years ago

It's because const is block scoped and you declared chatclient inside of a try/catch block here https://github.com/cameroncowden/datchatapp/blob/master/app.js#L231.

cameroncowden commented 6 years ago

Ahh, gotcha. lol, I'm creating new errors trying to catch my existing errors.

Looks like it's working now: dat://91e63e60d721216b7a2f67a45bc47e0a85e408e88ec347580cbde32a95c993a0/

One thing I'm noticing is that using archive.commit() just commits updates to the staging area. Is it possible for it to actually publish new changes?

pfrazee commented 6 years ago

Make sure you're using the latest beta of Beaker. We deprecated .commit()

cameroncowden commented 6 years ago

@pfrazee Ok, will do - is there a new way for dats to self-mutate without explicit user input?

pfrazee commented 6 years ago

Yeah you should be able to self mutate without prompts