diff --git a/pkg/interface/src/logic/api/chat.ts b/pkg/interface/src/logic/api/chat.ts index ad6e5029d..572c2fa58 100644 --- a/pkg/interface/src/logic/api/chat.ts +++ b/pkg/interface/src/logic/api/chat.ts @@ -81,7 +81,7 @@ export default class ChatApi extends BaseApi { * If we don't host the chat, then it just leaves */ delete(path: Path) { - this.viewAction({ delete: { 'app-path': path } }); + return this.viewAction({ delete: { 'app-path': path } }); } /** diff --git a/pkg/interface/src/views/apps/chat/components/join.js b/pkg/interface/src/views/apps/chat/components/join.js index 556bbe79a..282a76cab 100644 --- a/pkg/interface/src/views/apps/chat/components/join.js +++ b/pkg/interface/src/views/apps/chat/components/join.js @@ -41,13 +41,22 @@ export class JoinScreen extends Component { this.setState({ awaiting: true }, () => { const station = values.station.trim(); if (`/${station}` in props.chatSynced) { - props.history.push(`/~chat/room${station}`); + if (props.station) { + props.history.replace(`/~chat/room${station}`); + } else { + props.history.push(`/~chat/room${station}`); + } return; } const ship = station.substr(1).slice(0,station.substr(1).indexOf('/')); - props.api.chat.join(ship, station, true); - props.history.push(`/~chat/room${station}`); + props.api.chat.join(ship, station, true).then(() => { + if (props.station) { + props.history.replace(`/~chat/room${station}`); + } else { + props.history.push(`/~chat/room${station}`); + } + }); }); } diff --git a/pkg/interface/src/views/apps/chat/components/lib/delete-button.js b/pkg/interface/src/views/apps/chat/components/lib/delete-button.js index 1abb19f7e..1d123109a 100644 --- a/pkg/interface/src/views/apps/chat/components/lib/delete-button.js +++ b/pkg/interface/src/views/apps/chat/components/lib/delete-button.js @@ -1,6 +1,6 @@ import React, { memo } from 'react'; -export const DeleteButton = memo(({ isOwner, station, changeLoading, association, contacts, api }) => { +export const DeleteButton = memo(({ isOwner, station, changeLoading, association, contacts, api, history }) => { const leaveButtonClasses = (!isOwner) ? 'pointer' : 'c-default'; const deleteButtonClasses = (isOwner) ? 'b--red2 red2 pointer bg-gray0-d' : @@ -12,7 +12,9 @@ export const DeleteButton = memo(({ isOwner, station, changeLoading, association true, isOwner ? 'Deleting chat...' : 'Leaving chat...', () => { - api.chat.delete(station); + api.chat.delete(station).then(() => { + history.push("/~chat"); + }); } ); }; diff --git a/pkg/interface/src/views/apps/chat/components/settings.js b/pkg/interface/src/views/apps/chat/components/settings.js index 4e219350d..74d39c15a 100644 --- a/pkg/interface/src/views/apps/chat/components/settings.js +++ b/pkg/interface/src/views/apps/chat/components/settings.js @@ -67,7 +67,8 @@ export class SettingsScreen extends Component { groups, api, station, - match + match, + history } = this.props; const isOwner = deSig(match.params.ship) === window.ship; @@ -88,6 +89,7 @@ export class SettingsScreen extends Component { station={station} association={association} contacts={contacts} + history={history} api={api} /> { this.onClickJoin(); }); } - // once we've joined, push to group page + // once we've joined, replace to group page if (props.groups) { if (state.awaiting) { const group = `/ship/${state.group}`; if (group in props.groups) { - props.history.push(`/~groups${group}`); + if (props.ship && props.name) { + props.history.replace(`/~groups${group}`); + } else { + props.history.push(`/~groups${group}`); + } } } } diff --git a/pkg/interface/src/views/apps/publish/components/lib/Join.tsx b/pkg/interface/src/views/apps/publish/components/lib/Join.tsx index ff7a91c14..b12825acb 100644 --- a/pkg/interface/src/views/apps/publish/components/lib/Join.tsx +++ b/pkg/interface/src/views/apps/publish/components/lib/Join.tsx @@ -31,7 +31,7 @@ export function JoinScreen(props: JoinScreenProps & RouteComponentProps) { try { await api.publish.publishAction(action); await waiter((p) => !!p.notebooks?.[ship]?.[book]); - props.history.push(`/~publish/notebook/${ship}/${book}`); + props.history.replace(`/~publish/notebook/${ship}/${book}`); } catch (e) { console.error(e); setError(true);