diff options
Diffstat (limited to 'src/state/models')
-rw-r--r-- | src/state/models/navigation.ts | 18 | ||||
-rw-r--r-- | src/state/models/shell-ui.ts | 29 |
2 files changed, 18 insertions, 29 deletions
diff --git a/src/state/models/navigation.ts b/src/state/models/navigation.ts index 0ec097afc..a4d7d443b 100644 --- a/src/state/models/navigation.ts +++ b/src/state/models/navigation.ts @@ -222,6 +222,24 @@ export class NavigationModel { this.tabs.find(t => t.id === ptr[0])?.setTitle(ptr[1], title) } + handleLink(url: string) { + let path + if (url.startsWith('/')) { + path = url + } else if (url.startsWith('http')) { + try { + path = new URL(url).pathname + } catch (e) { + console.error('Invalid url', url, e) + return + } + } else { + console.error('Invalid url', url) + return + } + this.navigate(path) + } + // tab management // = diff --git a/src/state/models/shell-ui.ts b/src/state/models/shell-ui.ts index 73b1bd56e..13d720730 100644 --- a/src/state/models/shell-ui.ts +++ b/src/state/models/shell-ui.ts @@ -2,23 +2,6 @@ import {makeAutoObservable} from 'mobx' import {ProfileViewModel} from './profile-view' import * as Post from '../../third-party/api/src/client/types/app/bsky/feed/post' -export interface LinkActionsModelOpts { - newTab?: boolean -} -export class LinkActionsModel { - name = 'link-actions' - newTab: boolean - - constructor( - public href: string, - public title: string, - opts?: LinkActionsModelOpts, - ) { - makeAutoObservable(this) - this.newTab = typeof opts?.newTab === 'boolean' ? opts.newTab : true - } -} - export class ConfirmModel { name = 'confirm' @@ -31,14 +14,6 @@ export class ConfirmModel { } } -export class SharePostModel { - name = 'share-post' - - constructor(public href: string) { - makeAutoObservable(this) - } -} - export class EditProfileModel { name = 'edit-profile' @@ -85,9 +60,7 @@ export interface ComposerOpts { export class ShellUiModel { isModalActive = false activeModal: - | LinkActionsModel | ConfirmModel - | SharePostModel | EditProfileModel | CreateSceneModel | ServerInputModel @@ -101,9 +74,7 @@ export class ShellUiModel { openModal( modal: - | LinkActionsModel | ConfirmModel - | SharePostModel | EditProfileModel | CreateSceneModel | ServerInputModel, |