Skip to content

Commit

Permalink
fix(app): fix webpage and iframe view not compat with history; open n…
Browse files Browse the repository at this point in the history
…ew leaf to new split by default
  • Loading branch information
aidenlx committed Jan 11, 2024
1 parent c0c140d commit 0a4fe8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/app/src/media-view/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export abstract class MediaRemoteView
store;
scope: Scope;
root: ReactDOM.Root | null = null;
navigation = true;
protected _title = "";
protected _sourceType = "";

Expand Down
3 changes: 3 additions & 0 deletions apps/app/src/media-view/file-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ abstract class MediaFileView
implements PlayerComponent
{
allowNoFile = false;
// inherit from EditableFileView, no need to set explicitly
// navigation = true

// no need to manage scope manually,
// as it's implicitly called and handled by the WorkspaceLeaf
store;
Expand Down
9 changes: 7 additions & 2 deletions apps/app/src/mx-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export default class MxPlugin extends Plugin {
const leaf = existingPlayerLeaves[0];
leaf.setEphemeralState({ subpath: hash });
} else {
const leaf = this.app.workspace.getLeaf(newLeaf);
let leaf;
if (newLeaf) leaf = this.app.workspace.getLeaf("split", "vertical");
else leaf = this.app.workspace.getLeaf(false);
await leaf.setViewState(
{
type: MEDIA_EMBED_VIEW_TYPE,
Expand Down Expand Up @@ -117,8 +119,11 @@ export default class MxPlugin extends Plugin {
const { hash } = matchResult;
leaf.setEphemeralState({ subpath: hash });
} else {
const leaf = this.app.workspace.getLeaf(newLeaf);
let leaf;
if (newLeaf) leaf = this.app.workspace.getLeaf("split", "vertical");
else leaf = this.app.workspace.getLeaf(false);
const { hash, url } = matchResult;
// const view = await leaf.open(new MediaWebpageView(leaf, this));
await leaf.setViewState(
{
type: MEDIA_WEBPAGE_VIEW_TYPE,
Expand Down

0 comments on commit 0a4fe8a

Please sign in to comment.