mirror of
https://github.com/urbit/shrub.git
synced 2025-01-05 11:09:30 +03:00
chat-js + view: updated new page to work properly with group creation / selection
This commit is contained in:
parent
0d69e17f3b
commit
eada785c2c
@ -264,6 +264,9 @@
|
|||||||
++ create-metadata
|
++ create-metadata
|
||||||
|= [group-path=path app-path=path]
|
|= [group-path=path app-path=path]
|
||||||
^- (list card)
|
^- (list card)
|
||||||
|
~& group-path+group-path
|
||||||
|
~& app-path+app-path
|
||||||
|
~& is-managed+(is-managed app-path)
|
||||||
=/ =metadata
|
=/ =metadata
|
||||||
%* . *metadata
|
%* . *metadata
|
||||||
date-created now.bol
|
date-created now.bol
|
||||||
@ -346,7 +349,7 @@
|
|||||||
|= =path
|
|= =path
|
||||||
^- ?
|
^- ?
|
||||||
?> ?=(^ path)
|
?> ?=(^ path)
|
||||||
!=(path '~')
|
!=(i.path '~')
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ diff-chat-update
|
++ diff-chat-update
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -128,23 +128,27 @@ class UrbitApi {
|
|||||||
return this.action("chat-view", "json", data);
|
return this.action("chat-view", "json", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
chatViewCreate(path, security, members, allowHistory) {
|
chatViewCreate(appPath, groupPath, security, members, allowHistory) {
|
||||||
return this.chatViewAction({
|
return this.chatViewAction({
|
||||||
create: {
|
create: {
|
||||||
path, security, members,
|
'app-path': appPath,
|
||||||
|
'group-path': groupPath,
|
||||||
|
security,
|
||||||
|
members,
|
||||||
'allow-history': allowHistory
|
'allow-history': allowHistory
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
chatViewDelete(path) {
|
chatViewDelete(path) {
|
||||||
this.chatViewAction({ delete: { path } });
|
this.chatViewAction({ delete: { 'app-path': path } });
|
||||||
}
|
}
|
||||||
|
|
||||||
chatViewJoin(ship, path, askHistory) {
|
chatViewJoin(ship, path, askHistory) {
|
||||||
this.chatViewAction({
|
this.chatViewAction({
|
||||||
join: {
|
join: {
|
||||||
ship, path,
|
ship,
|
||||||
|
'app-path': path,
|
||||||
'ask-history': askHistory
|
'ask-history': askHistory
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -20,7 +20,6 @@ export class NewScreen extends Component {
|
|||||||
createGroup: true
|
createGroup: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.idName = React.createRef();
|
|
||||||
this.idChange = this.idChange.bind(this);
|
this.idChange = this.idChange.bind(this);
|
||||||
this.securityChange = this.securityChange.bind(this);
|
this.securityChange = this.securityChange.bind(this);
|
||||||
this.allowHistoryChange = this.allowHistoryChange.bind(this);
|
this.allowHistoryChange = this.allowHistoryChange.bind(this);
|
||||||
@ -46,20 +45,10 @@ export class NewScreen extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setInvite(value) {
|
setInvite(value) {
|
||||||
if (value.groups.length > 0) {
|
this.setState({
|
||||||
let idName = value.groups[0].split('/')[2];
|
groups: value.groups,
|
||||||
this.idName.current.value = idName;
|
ships: value.ships
|
||||||
this.setState({
|
});
|
||||||
idName,
|
|
||||||
groups: value.groups,
|
|
||||||
ships: value.ships
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.setState({
|
|
||||||
groups: value.groups,
|
|
||||||
ships: value.ships
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
securityChange(event) {
|
securityChange(event) {
|
||||||
@ -149,17 +138,25 @@ export class NewScreen extends Component {
|
|||||||
// if we want a "proper group" that can be managed from the contacts UI,
|
// if we want a "proper group" that can be managed from the contacts UI,
|
||||||
// we make a path of the form /~zod/cool-group
|
// we make a path of the form /~zod/cool-group
|
||||||
// if not, we make a path of the form /~/~zod/free-chat
|
// if not, we make a path of the form /~/~zod/free-chat
|
||||||
let chatPath = `/~${window.ship}${station}`;
|
let appPath = `/~${window.ship}${station}`;
|
||||||
if (!state.createGroup && state.groups.length === 0) {
|
if (!state.createGroup && state.groups.length === 0) {
|
||||||
chatPath = `/~${chatPath}`;
|
appPath = `/~${appPath}`;
|
||||||
|
}
|
||||||
|
let groupPath = appPath;
|
||||||
|
if (state.groups.length > 0) {
|
||||||
|
groupPath = state.groups[0];
|
||||||
}
|
}
|
||||||
let submit = props.api.chatView.create(
|
let submit = props.api.chatView.create(
|
||||||
chatPath, state.security, aud, state.allowHistory
|
appPath,
|
||||||
);
|
groupPath,
|
||||||
submit.then(() => {
|
state.security,
|
||||||
props.api.setSpinner(false);
|
aud,
|
||||||
props.history.push(`/~chat/room${chatPath}`);
|
state.allowHistory
|
||||||
})
|
);
|
||||||
|
submit.then(() => {
|
||||||
|
props.api.setSpinner(false);
|
||||||
|
props.history.push(`/~chat/room${appPath}`);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,9 +180,6 @@ export class NewScreen extends Component {
|
|||||||
let idClasses =
|
let idClasses =
|
||||||
"f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 db w-100 " +
|
"f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 db w-100 " +
|
||||||
"focus-b--black focus-b--white-d ";
|
"focus-b--black focus-b--white-d ";
|
||||||
if (state.groups.length > 0) {
|
|
||||||
idClasses = idClasses + " o-40";
|
|
||||||
}
|
|
||||||
|
|
||||||
let idErrElem = (<span />);
|
let idErrElem = (<span />);
|
||||||
if (state.idError) {
|
if (state.idError) {
|
||||||
@ -237,8 +231,6 @@ export class NewScreen extends Component {
|
|||||||
resize: "none"
|
resize: "none"
|
||||||
}}
|
}}
|
||||||
onChange={this.idChange}
|
onChange={this.idChange}
|
||||||
ref={this.idName}
|
|
||||||
disabled={(state.groups.length > 0) ? "disabled" : false}
|
|
||||||
/>
|
/>
|
||||||
{idErrElem}
|
{idErrElem}
|
||||||
<p className="f8 mt4 lh-copy db">
|
<p className="f8 mt4 lh-copy db">
|
||||||
|
@ -34,6 +34,10 @@ export class Subscription {
|
|||||||
this.handleEvent.bind(this),
|
this.handleEvent.bind(this),
|
||||||
this.handleError.bind(this),
|
this.handleError.bind(this),
|
||||||
this.handleQuitAndResubscribe.bind(this));
|
this.handleQuitAndResubscribe.bind(this));
|
||||||
|
api.bind('/app-name/chat', 'PUT', api.authTokens.ship, 'metadata-store',
|
||||||
|
this.handleEvent.bind(this),
|
||||||
|
this.handleError.bind(this),
|
||||||
|
this.handleQuitAndResubscribe.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(diff) {
|
handleEvent(diff) {
|
||||||
|
Loading…
Reference in New Issue
Block a user