summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-11-12 10:32:46 +0700
committerpolwex <polwex@sortug.com>2025-11-12 10:32:46 +0700
commitab786760a16c07031fa9b7e8987ebe755a57912c (patch)
treefae744eb25a196d8fe94a95be55c246ac3679545
parent284ce9ce7d9f81e54e91f917329d48926487fbf4 (diff)
further fixes to engagement flow
-rw-r--r--app/app/nostrill.hoon1
-rw-r--r--app/lib/mutations/trill.hoon214
-rw-r--r--app/lib/nostr/client.hoon19
-rw-r--r--gui/src/components/composer/Composer.tsx14
-rw-r--r--gui/src/components/post/Footer.tsx32
-rw-r--r--gui/src/components/post/Header.tsx1
-rw-r--r--gui/src/logic/requests/nostrill.ts25
7 files changed, 195 insertions, 111 deletions
diff --git a/app/app/nostrill.hoon b/app/app/nostrill.hoon
index 52cb8bb..b89f7f7 100644
--- a/app/app/nostrill.hoon
+++ b/app/app/nostrill.hoon
@@ -164,7 +164,6 @@
::
++ on-ui
=/ jon=json !<(json vase)
- ~& > on-ui-jon=jon
=/ upoke=(unit poke:ui:sur) (ui:de:jsonlib jon)
?~ upoke ~& bad-ui-poke=jon `this
?- -.u.upoke
diff --git a/app/lib/mutations/trill.hoon b/app/lib/mutations/trill.hoon
index cfedecf..653a493 100644
--- a/app/lib/mutations/trill.hoon
+++ b/app/lib/mutations/trill.hoon
@@ -24,69 +24,172 @@
=. feed.state (put:orm:feed feed.state id.p p)
state
++ headsup-poke
- |= [poke=post-poke:ui:sur p=post:post] ^- (unit engagement:comms)
+ |= [poke=post-poke:ui:sur p=post:post] ^- engagement:comms
?- -.poke
- %add ~
- ::: TODO del-reply
- %del ~
- %quote `[%quote id.poke p]
- %reply `[%reply id.poke p]
- %rp `[%rp id.poke id.p]
- %reaction `[%reaction id.poke reaction.poke]
+ %add !!
+ %del !!
+ %quote [%quote id.poke p]
+ :: TODO del-reply
+ %reply [%reply id.poke p]
+ %rp [%rp id.poke id.p]
+ %reaction [%reaction id.poke reaction.poke]
==
++ handle-post |= poke=post-poke:ui:sur
^- (quip card _state)
+ ~& handle-post-ui=poke
=/ profile (~(get by profiles.state) [%urbit our.bowl])
=/ pubkey pub.i.keys.state
- ?: ?=(%del -.poke)
- =. feed.state =< + (del:orm:feed feed.state id.poke)
- :: TODO
- `state
- =/ p=post:post
+ =/ crds ~(. cards:lib bowl)
+
?- -.poke
+ %del =. feed.state =< + (del:orm:feed feed.state id.poke)
+ :: TODO cascade children
+ =/ p *post:post
+ =/ p p(id id.poke, host host.poke)
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %del pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ :_ state
+ ?: .=(our.bowl host.p)
+ =/ =fact:comms [%post %del id.poke]
+ =/ fact-card (update-followers:cards:lib fact)
+ :~ ui-card
+ fact-card
+ ==
+ ::
+ :~ ui-card
+ ==
%add
=/ sp (build-sp:trill our.bowl our.bowl content.poke ~ ~)
- (build-post:trill now.bowl pubkey sp)
+ =/ p=post:post
+ (build-post:trill now.bowl pubkey sp)
+ =. state (add-to-feed p)
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ :_ state
+ =/ =fact:comms [%post %add p]
+ =/ fact-card (update-followers:cards:lib fact)
+ :~ ui-card
+ fact-card
+ ==
%quote
=/ sp (build-sp:trill our.bowl our.bowl content.poke ~ ~)
=/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
=. contents.sp (snoc contents.sp quote)
- (build-post:trill now.bowl pubkey sp)
+ =/ p=post:post
+ (build-post:trill now.bowl pubkey sp)
+ =. state (add-to-feed p)
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ =/ eng-poke [%eng (headsup-poke poke p)]
+ =/ eng-card (poke-host:crds host.p eng-poke)
+
+ :_ state
+ ?: .=(our.bowl host.poke)
+ =/ =fact:comms [%post %add p]
+ =/ fact-card (update-followers:cards:lib fact)
+ :~ ui-card
+ fact-card
+ eng-card
+ ==
+ ::
+ :~ ui-card
+ eng-card
+ ==
+
%reply
=/ sp (build-sp:trill host.poke our.bowl content.poke `id.poke `thread.poke)
- (build-post:trill now.bowl pubkey sp)
+ =/ p=post:post
+ (build-post:trill now.bowl pubkey sp)
+ =. state (add-to-feed p)
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ =/ eng-poke [%eng (headsup-poke poke p)]
+ =/ eng-card (poke-host:crds host.p eng-poke)
+
+ :_ state
+ ?: .=(our.bowl host.poke)
+ =/ =fact:comms [%post %add p]
+ =/ fact-card (update-followers:cards:lib fact)
+ :~ ui-card
+ fact-card
+ eng-card
+ ==
+ ::
+ :~ ui-card
+ eng-card
+ ==
%rp
=/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
=/ sp (build-sp:trill host.poke our.bowl '' ~ ~)
=. contents.sp ~[quote]
- (build-post:trill now.bowl pubkey sp)
+ =/ p=post:post
+ (build-post:trill now.bowl pubkey sp)
+ =. state (add-to-feed p)
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ =/ eng-poke [%eng (headsup-poke poke p)]
+ =/ eng-card (poke-host:crds host.p eng-poke)
+
+ :_ state
+ ?: .=(our.bowl host.poke)
+ =/ =fact:comms [%post %add p]
+ =/ fact-card (update-followers:cards:lib fact)
+ :~ ui-card
+ fact-card
+ eng-card
+ ==
+ ::
+ :~ ui-card
+ eng-card
+ ==
%reaction
- =/ p (got:orm:feed feed.state id.poke)
- =. reacts.engagement.p %+ ~(put by reacts.engagement.p)
- our.bowl [reaction.poke *signature:post]
- p
+ ?: .=(host.poke our.bowl)
+ =/ p (got:orm:feed feed.state id.poke)
+ =. reacts.engagement.p %+ ~(put by reacts.engagement.p)
+ our.bowl [reaction.poke *signature:post]
+ =. state (add-to-feed p)
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ =/ eng-poke [%eng (headsup-poke poke p)]
+ =/ eng-card (poke-host:crds host.poke eng-poke)
+
+ :_ state
+ =/ =fact:comms [%post %add p]
+ =/ fact-card (update-followers:cards:lib fact)
+ :~ ui-card
+ fact-card
+ eng-card
+ ==
+ ::
+ =/ up (get:orm:feed following2.state id.poke)
+ ?~ up
+ =/ eng-poke [%eng (headsup-poke poke *post:post)]
+ =/ eng-card (poke-host:crds host.poke eng-poke)
+ :_ state :~(eng-card)
+ ::
+ =/ p u.up
+ =. reacts.engagement.p %+ ~(put by reacts.engagement.p)
+ our.bowl [reaction.poke *signature:post]
+ =. state (add-to-feed p)
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ =/ eng-poke [%eng (headsup-poke poke p)]
+ =/ eng-card (poke-host:crds host.p eng-poke)
+
+ :_ state
+ =/ =fact:comms [%post %add p]
+ :~ ui-card
+ eng-card
+ ==
==
- =. state (add-to-feed p)
- =/ pw [p (some pubkey) ~ ~ profile]
- =/ jfact=fact:ui:sur [%post %add pw]
- =/ ui-card (update-ui:cards:lib jfact)
- =/ crds ~(. cards:lib bowl)
- =/ engagement-poke (headsup-poke poke p)
- =/ base-cards
- ?~ engagement-poke :~(ui-card)
- =/ poke [%eng u.engagement-poke]
- =/ eng-card (poke-host:crds host.p poke)
- :~(ui-card eng-card)
- :: if our own post we update followers, if someone elses post we send an engagement poke
- :_ state
- ?: .=(our.bowl host.p)
- ::
- =/ =fact:comms [%post %add p]
- =/ fact-card (update-followers:cards:lib fact)
- :- fact-card base-cards
- ::
- base-cards
++ handle-post-fact |= pf=post-fact:comms
^- (quip card _state)
@@ -94,17 +197,30 @@
=/ =user:sur [%urbit src.bowl]
=/ fed (~(get by following.state) user)
?~ fed ~& "emmm not following ya" `state
- =/ nf=feed:feed
- ?: ?=(%del -.pf)
- =< + (del:orm:feed u.fed id.pf)
- ::mmm people aren't supposed to update if its not their own feeds
- :: =/ =user:nsur [%urbit host.p.pdf]
- (put:orm:feed u.fed id.p.pf p.pf)
+ =/ nf=feed:feed
+ ?: ?=(%del -.pf)
+ =< + (del:orm:feed u.fed id.pf)
+ ::mmm people aren't supposed to update if its not their own feeds
+ :: =/ =user:nsur [%urbit host.p.pdf]
+ (put:orm:feed u.fed id.p.pf p.pf)
=. following.state (~(put by following.state) user nf)
=. following2.state
?: ?=(%del -.pf)
=< + (del:orm:feed following2.state id.pf)
(insert-to-global:trill-feed nf p.pf)
- :: TODO update the ui with the changes
- :_ state ~
+ :: TODO update the ui with the changes
+ :_ state
+ =/ profile (~(get by profiles.state) user)
+ =/ pubkey 0 :: TODO
+ =/ jfact=fact:ui:sur
+ ?: ?=(%del -.pf)
+ =/ p *post:post
+ =/ p p(host src.bowl, id id.pf)
+ =/ pw [p ~ ~ ~ profile]
+ [%post %del pw]
+ =/ pw [p.pf ~ ~ ~ profile]
+ [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ :~ ui-card
+ ==
--
diff --git a/app/lib/nostr/client.hoon b/app/lib/nostr/client.hoon
index c258258..1cda3e3 100644
--- a/app/lib/nostr/client.hoon
+++ b/app/lib/nostr/client.hoon
@@ -100,17 +100,22 @@
++ send
|= [relay-url=@t req=client-msg:nsur] ^- card:agent:gall
- ~& >>> send=relay-url
+ ~& >>> sendws=relay-url
=/ req-body=json (req:en:js req)
=/ octs (json-to-octs:server req-body)
=/ wmsg=websocket-message:eyre [1 `octs]
- =/ conn (check-connected:ws relay-url bowl)
- ~& >>> send-client-conn=conn
- ?~ conn :: if no ws connection we start a thread which will connect first, then send the message
- =/ pat /to-nostr-relay
- [%pass (weld /ws pat) %arvo %k %fard dap.bowl %ws %noun !>([relay-url wmsg])]
+ ~& >> sup=sup.bowl
+ :: =/ conn (check-connected:ws relay-url bowl)
+ :: ~& >>> send-client-conn=conn
+ :: ?~ conn :: if no ws connection we start a thread which will connect first, then send the message
+ :: =/ pat /to-nostr-relay
+ :: [%pass (weld /ws pat) %arvo %k %fard dap.bowl %ws %noun !>([relay-url wmsg])]
::
- (give-ws-payload-client:ws id.u.conn wmsg)
+ :: (give-ws-payload-client:ws id.u.conn wmsg)
+ :: (give-ws-payload-client:ws wid wmsg)
+
+ =/ =task:iris [%websocket-connect dap.bowl relay-url]
+ [%pass /ws-req/nostrill %arvo %i task]
:: ++ send-http
diff --git a/gui/src/components/composer/Composer.tsx b/gui/src/components/composer/Composer.tsx
index 81d0358..8b7e343 100644
--- a/gui/src/components/composer/Composer.tsx
+++ b/gui/src/components/composer/Composer.tsx
@@ -1,5 +1,4 @@
import useLocalState from "@/state/state";
-import type { Poast } from "@/types/trill";
import Sigil from "@/components/Sigil";
import { useState, useEffect, useRef, type FormEvent } from "react";
import Snippets, { ReplySnippet } from "./Snippets";
@@ -42,19 +41,6 @@ function Composer({ isAnon }: { isAnon?: boolean }) {
async function poast(e: FormEvent<HTMLFormElement>) {
e.preventDefault();
// TODO
- // const parent = replying ? replying : null;
- // const tokens = tokenize(input);
- // const post: SentPoast = {
- // host: parent ? parent.host : our,
- // author: our,
- // thread: parent ? parent.thread : null,
- // parent: parent ? parent.id : null,
- // contents: input,
- // read: openLock,
- // write: openLock,
- // tags: input.match(HASHTAGS_REGEX) || [],
- // };
- // TODO make it user choosable
setLoading(true);
const res =
diff --git a/gui/src/components/post/Footer.tsx b/gui/src/components/post/Footer.tsx
index a87c1f8..87f45f3 100644
--- a/gui/src/components/post/Footer.tsx
+++ b/gui/src/components/post/Footer.tsx
@@ -51,7 +51,7 @@ function Footer({ poast, refetch }: PostProps) {
async function cancelRP(e: React.MouseEvent) {
e.stopPropagation();
e.preventDefault();
- const r = await api!.deletePost(our);
+ const r = await api!.deletePost(poast.host, poast.id);
if (r) toast.success("Repost deleted");
// refetch();
if (location.includes(poast.id)) navigate("/");
@@ -60,31 +60,11 @@ function Footer({ poast, refetch }: PostProps) {
// TODO update backend because contents are only markdown now
e.stopPropagation();
e.preventDefault();
- // const c = [
- // {
- // ref: {
- // type: "trill",
- // ship: poast.host,
- // path: `/${poast.id}`,
- // },
- // },
- // ];
- // const post: SentPoast = {
- // host: our,
- // author: our,
- // thread: null,
- // parent: null,
- // contents: input,
- // read: openLock,
- // write: openLock,
- // tags: [], // TODO
- // };
- // const r = await api!.addPost(post, false);
- // setReposting(true);
- // if (r) {
- // setReposting(false);
- // toast.success("Your post was published");
- // }
+ const pid = { ship: poast.host, id: poast.id };
+ const r = await api!.addRP(pid);
+ if (r) {
+ toast.success("Your repost was published");
+ }
}
function doReact(e: React.MouseEvent) {
e.stopPropagation();
diff --git a/gui/src/components/post/Header.tsx b/gui/src/components/post/Header.tsx
index 4e72fe8..0dfd5e4 100644
--- a/gui/src/components/post/Header.tsx
+++ b/gui/src/components/post/Header.tsx
@@ -10,6 +10,7 @@ function Header(props: PostProps) {
// console.log(props.poast.author.length, "length");
function go(e: React.MouseEvent) {
e.stopPropagation();
+ navigate(`/feed/${poast.host}`);
}
function openThread(e: React.MouseEvent) {
e.stopPropagation();
diff --git a/gui/src/logic/requests/nostrill.ts b/gui/src/logic/requests/nostrill.ts
index e35b939..81f0bb1 100644
--- a/gui/src/logic/requests/nostrill.ts
+++ b/gui/src/logic/requests/nostrill.ts
@@ -108,7 +108,7 @@ export default class IO {
return this.poke({ post: json });
}
async addRP(pid: PID) {
- const json = { quote: { host: pid.ship, id: pid.id } };
+ const json = { rp: { host: pid.ship, id: pid.id } };
return this.poke({ post: json });
}
@@ -122,29 +122,26 @@ export default class IO {
// return this.poke(json);
// }
- async deletePost(id: string) {
- const host = `~${this.airlock.ship}`;
+ async deletePost(host: Ship, id: string) {
const json = {
- "del-post": {
- ship: host,
- id: id,
+ del: {
+ host,
+ id,
},
};
- return this.poke(json);
+ return this.poke({ post: json });
}
async addReact(ship: Ship, id: PostID, reaction: string) {
const json = {
- "new-react": {
- react: reaction,
- pid: {
- id: id,
- ship: ship,
- },
+ reaction: {
+ reaction: reaction,
+ id: id,
+ host: ship,
},
};
- return this.poke(json);
+ return this.poke({ post: json });
}
// follows