mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-03 04:40:50 +03:00
chat-hook: updated to allow a simpler message send flow
This commit is contained in:
parent
693b6f2b81
commit
8b74a674f3
@ -41,7 +41,7 @@
|
||||
++ poke-noun
|
||||
|= a=*
|
||||
^- (quip move _this)
|
||||
~& bol
|
||||
~& synced
|
||||
[~ this]
|
||||
::
|
||||
++ poke-json
|
||||
@ -55,11 +55,12 @@
|
||||
?> ?=(%message -.act)
|
||||
:: local
|
||||
?: =(src.bol our.bol)
|
||||
=/ ship (~(get by synced) path.act)
|
||||
?~ ship
|
||||
?. (~(has by synced) path.act)
|
||||
[~ this]
|
||||
=/ ship (~(got by synced) path.act)
|
||||
=/ appl ?:(=(ship our.bol) %chat-store %chat-hook)
|
||||
:_ this
|
||||
[ost.bol %poke / [u.ship %chat-store] [%chat-action act]]~
|
||||
[ost.bol %poke / [ship appl] [%chat-action act]]~
|
||||
:: foreign
|
||||
=/ ship (~(get by synced) path.act)
|
||||
?~ ship
|
||||
@ -145,7 +146,7 @@
|
||||
?~ pax !!
|
||||
?. (~(has by synced) pax) !!
|
||||
:: scry permissions to check if read is permitted
|
||||
?. (permitted-scry [(scot %p src.bol) %chat (weld pax /write)])
|
||||
?. (permitted-scry [(scot %p src.bol) %chat (weld pax /read)])
|
||||
!!
|
||||
=/ box=(unit mailbox) (chat-scry pax)
|
||||
?~ box !!
|
||||
|
File diff suppressed because one or more lines are too long
@ -13,27 +13,23 @@
|
||||
:~
|
||||
[%add-owned add-owned]
|
||||
[%add-synced add-synced]
|
||||
[%remove remove]
|
||||
[%remove pa]
|
||||
==
|
||||
::
|
||||
++ add-owned
|
||||
%- ot
|
||||
:~ [%path (su ;~(pfix net (more net urs:ab)))]
|
||||
[%security sec]
|
||||
:~ [%path pa]
|
||||
[%security sec]
|
||||
==
|
||||
::
|
||||
++ add-synced
|
||||
%- ot
|
||||
:~ [%ship (su ;~(pfix sig fed:ag))]
|
||||
[%path (su ;~(pfix net (more net urs:ab)))]
|
||||
[%path pa]
|
||||
==
|
||||
::
|
||||
++ remove
|
||||
(su ;~(pfix net (more net urs:ab)))
|
||||
::
|
||||
++ sec
|
||||
=, dejs:format
|
||||
^- $-(json chat-security)
|
||||
^- $-(^json chat-security)
|
||||
(su (perk %channel %village %journal %mailbox ~))
|
||||
::
|
||||
--
|
||||
|
@ -146,7 +146,7 @@ class UrbitApi {
|
||||
this.chatAction({ delete: { path } });
|
||||
}
|
||||
|
||||
chatMessage(local, path, author, when, letter) {
|
||||
chatMessage(path, author, when, letter) {
|
||||
let data = {
|
||||
message: {
|
||||
path,
|
||||
@ -160,12 +160,8 @@ class UrbitApi {
|
||||
}
|
||||
};
|
||||
|
||||
this.chatHookAction(data, "json");
|
||||
this.addPendingMessage(data.message);
|
||||
if (local) {
|
||||
this.chatAction(data);
|
||||
} else {
|
||||
this.chatHookAction(data, "json");
|
||||
}
|
||||
}
|
||||
|
||||
chatRead(path, read) {
|
||||
|
@ -28,7 +28,6 @@ export class ChatInput extends Component {
|
||||
/*let closure = () => {
|
||||
for (var i = 0; i < 30; i++) {
|
||||
props.api.chat.message(
|
||||
props.owner === `${window.ship}`,
|
||||
props.station,
|
||||
`~${window.ship}`,
|
||||
Date.now(),
|
||||
@ -91,7 +90,8 @@ export class ChatInput extends Component {
|
||||
|
||||
return {
|
||||
code: {
|
||||
expression: letter
|
||||
expression: letter,
|
||||
output: undefined
|
||||
}
|
||||
}
|
||||
} else if (this.isUrl(letter)) {
|
||||
@ -128,7 +128,6 @@ export class ChatInput extends Component {
|
||||
let letter = this.getLetterType(state.message);
|
||||
|
||||
props.api.chat.message(
|
||||
props.owner === `${window.ship}`,
|
||||
props.station,
|
||||
`~${window.ship}`,
|
||||
Date.now(),
|
||||
|
@ -10,6 +10,7 @@ export class Message extends Component {
|
||||
renderContent() {
|
||||
const { props } = this;
|
||||
let letter = props.msg.letter;
|
||||
console.log(props.msg);
|
||||
|
||||
if ('code' in letter) {
|
||||
return (
|
||||
@ -18,7 +19,10 @@ export class Message extends Component {
|
||||
{letter.code.expression}
|
||||
</pre>
|
||||
<pre className="clamp-attachment pa1 mt0 mb0">
|
||||
{letter.code.output[0].join('\n')}
|
||||
{ !!letter.code.output && letter.code.output.length ?
|
||||
( letter.code.output[0].join('\n') ) :
|
||||
''
|
||||
}
|
||||
</pre>
|
||||
</span>
|
||||
);
|
||||
|
@ -31,7 +31,7 @@ export class SettingsScreen extends Component {
|
||||
deleteChat() {
|
||||
const { props, state } = this;
|
||||
|
||||
props.api.chatView.remove(state.station);
|
||||
props.api.chatView.delete(state.station);
|
||||
props.setSpinner(true);
|
||||
|
||||
this.setState({
|
||||
|
@ -49,7 +49,6 @@ export class Subscription {
|
||||
}
|
||||
|
||||
handleQuitAndResubscribe(quit) {
|
||||
console.error(quit);
|
||||
// TODO: resubscribe
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user