Skip to content

Commit 1d15b1e

Browse files
Merge pull request #1093 from lightninglabs/path-prefix-custom-session
app: fix custom session routes with path prefix
2 parents eb7b771 + 04d6ac4 commit 1d15b1e

File tree

4 files changed

+32
-22
lines changed

4 files changed

+32
-22
lines changed

app/src/components/connect/CustomSessionPage.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import React, { FormEvent, useCallback } from 'react';
2+
import { Collapse } from 'react-collapse';
23
import { observer } from 'mobx-react-lite';
34
import styled from '@emotion/styled';
4-
import { useStore } from 'store';
55
import { usePrefixedTranslation } from 'hooks';
6-
import { Collapse } from 'react-collapse';
7-
import { Column, Row, ChevronUp, ChevronDown } from 'components/base';
8-
import { Paragraph, Small, Label } from 'components/common/v2/Text';
9-
import OverlayFormWrap from 'components/common/OverlayFormWrap';
6+
import { useStore } from 'store';
7+
import { PermissionTypeValues } from 'store/views/addSessionView';
8+
import { ChevronDown, ChevronUp, Column, Row } from 'components/base';
9+
import FormDate from 'components/common/FormDate';
1010
import FormField from 'components/common/FormField';
1111
import FormInput from 'components/common/FormInput';
1212
import FormInputNumber from 'components/common/FormInputNumber';
1313
import FormSelect from 'components/common/FormSelect';
14-
import FormDate from 'components/common/FormDate';
14+
import OverlayFormWrap from 'components/common/OverlayFormWrap';
1515
import FormSwitch from 'components/common/v2/FormSwitch';
16+
import { Label, Paragraph, Small } from 'components/common/v2/Text';
1617
import PurpleButton from './PurpleButton';
17-
import { PermissionTypeValues } from 'store/views/addSessionView';
1818

1919
const Styled = {
2020
Wrapper: styled.div`
@@ -101,7 +101,7 @@ const CustomSessionPage: React.FC = () => {
101101

102102
const handleBack = useCallback(() => {
103103
addSessionView.cancel();
104-
appView.goTo('/connect');
104+
appView.goToConnect();
105105
}, [appView]);
106106

107107
const handleSubmit = useCallback(async (event: FormEvent<HTMLFormElement>) => {

app/src/store/views/addSessionView.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makeAutoObservable, observable } from 'mobx';
2-
import { Store } from 'store';
32
import * as LIT from 'types/generated/lit-sessions_pb';
43
import { MAX_DATE, PermissionUriMap } from 'util/constants';
4+
import { Store } from 'store';
55

66
export enum PermissionTypeValues {
77
Admin = 'admin',
@@ -216,8 +216,7 @@ export default class AddSessionView {
216216

217217
async handleSubmit() {
218218
if (this.permissionType === PermissionTypeValues.Custom) {
219-
this._store.settingsStore.sidebarVisible = false;
220-
this._store.router.push('/connect/custom');
219+
this._store.appView.goToConnectCustom();
221220
} else {
222221
const session = await this._store.sessionStore.addSession(
223222
this.label,
@@ -264,7 +263,7 @@ export default class AddSessionView {
264263

265264
if (session) {
266265
this.cancel();
267-
this._store.router.push('/connect');
266+
this._store.appView.goToConnect();
268267
}
269268
}
270269

app/src/store/views/appView.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,28 @@ export default class AppView {
3434

3535
/** navigate to the specified route */
3636
goTo(route: string) {
37-
if (this._store.router.location.pathname !== route) {
38-
this._store.router.push(route);
37+
const path = `${PUBLIC_URL}${route}`;
38+
if (this._store.router.location.pathname !== path) {
39+
this._store.router.push(path);
3940
}
4041
}
4142

4243
/** Change to the Auth page */
4344
gotoAuth() {
44-
this.goTo(`${PUBLIC_URL}/`);
45+
this.goTo(`/`);
4546
this._store.log.info('Go to the Auth page');
4647
}
4748

4849
/** Change to the Home page */
4950
goToHome() {
50-
this.goTo(`${PUBLIC_URL}/home`);
51+
this.goTo(`/home`);
5152
this._store.settingsStore.autoCollapseSidebar();
5253
this._store.log.info('Go to the Home page');
5354
}
5455

5556
/** Change to the Loop page */
5657
goToLoop() {
57-
this.goTo(`${PUBLIC_URL}/loop`);
58+
this.goTo(`/loop`);
5859
this._store.settingsStore.autoCollapseSidebar();
5960
if (!this._store.settingsStore.tourAutoShown) {
6061
this.showTour();
@@ -65,33 +66,40 @@ export default class AppView {
6566

6667
/** Change to the History page */
6768
goToHistory() {
68-
this.goTo(`${PUBLIC_URL}/history`);
69+
this.goTo(`/history`);
6970
this._store.settingsStore.autoCollapseSidebar();
7071
this._store.log.info('Go to the History page');
7172
}
7273

7374
/** Change to the Pool page */
7475
goToPool() {
75-
this.goTo(`${PUBLIC_URL}/pool`);
76+
this.goTo(`/pool`);
7677
// always collapse the sidebar to make room for the Pool sidebar
7778
this._store.settingsStore.sidebarVisible = false;
7879
this._store.log.info('Go to the Pool page');
7980
}
8081

8182
/** Change to the Settings page */
8283
goToSettings() {
83-
this.goTo(`${PUBLIC_URL}/settings`);
84+
this.goTo(`/settings`);
8485
this._store.settingsStore.autoCollapseSidebar();
8586
this._store.log.info('Go to the Settings page');
8687
}
8788

8889
/** Change to the Connect page */
8990
goToConnect() {
90-
this.goTo(`${PUBLIC_URL}/connect`);
91+
this.goTo(`/connect`);
9192
this._store.settingsStore.autoCollapseSidebar();
9293
this._store.log.info('Go to the Connect page');
9394
}
9495

96+
/** Change to the Connect Custom page */
97+
goToConnectCustom() {
98+
this.goTo(`/connect/custom`);
99+
this._store.settingsStore.autoCollapseSidebar();
100+
this._store.log.info('Go to the Connect Custom page');
101+
}
102+
95103
/** Toggle displaying of the Processing Loops section */
96104
toggleProcessingSwaps() {
97105
this.processingSwapsVisible = !this.processingSwapsVisible;
@@ -178,7 +186,7 @@ export default class AppView {
178186
/** sets the selected setting to display */
179187
showSettings(name: SettingName) {
180188
const path = name === '' ? '' : `/${name}`;
181-
this.goTo(`${PUBLIC_URL}/settings${path}`);
189+
this.goTo(`/settings${path}`);
182190
this._store.log.info('Switch to Setting screen', name);
183191
}
184192

docs/release-notes/release-notes-0.15.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
### Bug Fixes
1717

18+
* [Fixed navigation issues](https://github.com/lightninglabs/lightning-terminal/pull/1093)
19+
when creating a custom Lightning Node Connect session via the UI.
20+
1821
### Functional Changes/Additions
1922

2023
* [`litcli`: global flags to allow overrides via environment

0 commit comments

Comments
 (0)