chat fe: support groupify operation

This commit is contained in:
Fang 2020-03-13 18:14:57 +01:00
parent 9793dccef0
commit 32ae34a37a
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
3 changed files with 56 additions and 5 deletions

View File

@ -24,6 +24,7 @@ class UrbitApi {
create: this.chatViewCreate.bind(this), create: this.chatViewCreate.bind(this),
delete: this.chatViewDelete.bind(this), delete: this.chatViewDelete.bind(this),
join: this.chatViewJoin.bind(this), join: this.chatViewJoin.bind(this),
groupify: this.chatViewGroupify.bind(this)
}; };
this.chatHook = { this.chatHook = {
@ -174,6 +175,10 @@ class UrbitApi {
}); });
} }
chatViewGroupify(path) {
return this.chatViewAction({ groupify: { 'app-path': path } });
}
inviteAction(data) { inviteAction(data) {
this.action("invite-store", "json", data); this.action("invite-store", "json", data);
} }

View File

@ -259,6 +259,11 @@ export class Root extends Component {
let popout = props.match.url.includes("/popout/"); let popout = props.match.url.includes("/popout/");
let permission = state.permissions[station] || {
kind: "",
who: new Set([])
};
let association = let association =
station in associations["chat"] ? associations.chat[station] : {}; station in associations["chat"] ? associations.chat[station] : {};
@ -274,6 +279,7 @@ export class Root extends Component {
{...props} {...props}
station={station} station={station}
association={association} association={association}
permission={permission}
api={api} api={api}
station={station} station={station}
group={group} group={group}

View File

@ -76,7 +76,22 @@ export class SettingsScreen extends Component {
props.api.setSpinner(true); props.api.setSpinner(true);
this.setState({ this.setState({
isLoading: true isLoading: true,
loadingText: (deSig(props.match.params.ship) === window.ship)
? 'Deleting...'
: 'Leaving...'
});
}
groupifyChat() {
const { props, state } = this;
props.api.chatView.groupify(props.station);
props.api.setSpinner(true);
this.setState({
isLoading: true,
loadingText: 'Converting...'
}); });
} }
@ -106,6 +121,33 @@ export class SettingsScreen extends Component {
); );
} }
renderGroupify() {
const { props, state } = this;
const chatOwner = (deSig(props.match.params.ship) === window.ship);
console.log(chatOwner, props.match.params.ship, window.ship);
const ownedUnmanagedVillage =
chatOwner &&
props.station.slice(0, 3) === '/~/' &&
props.permission.kind === 'white';
if (!ownedUnmanagedVillage) {
return null;
} else {
return (
<div>
<div className={"w-100 fl mt3 "}>
<p className="f8 mt3 lh-copy db">Convert Chat</p>
<p className="f9 gray2 db mb4">Convert this chat into a group + associated chat.</p>
<a onClick={this.groupifyChat.bind(this)}
className={"dib f9 black gray4-d bg-gray0-d ba pa2 b--black b--gray1-d pointer"}>Convert to group</a>
</div>
</div>
);
}
}
renderMetadataSettings() { renderMetadataSettings() {
const { props, state } = this; const { props, state } = this;
@ -210,10 +252,7 @@ export class SettingsScreen extends Component {
let writeGroup = Array.from(props.group.values()); let writeGroup = Array.from(props.group.values());
if (!!state.isLoading) { if (!!state.isLoading) {
let text = "Deleting..."; let text = state.loadingText || 'Working...';
if (deSig(props.match.params.ship) !== window.ship) {
text = "Leaving...";
}
let title = props.station.substr(1); let title = props.station.substr(1);
@ -321,6 +360,7 @@ export class SettingsScreen extends Component {
</span> </span>
</div> </div>
</div> </div>
{this.renderGroupify()}
{this.renderDelete()} {this.renderDelete()}
{this.renderMetadataSettings()} {this.renderMetadataSettings()}
</div> </div>