Skip to content

Commit

Permalink
feat: add notice for init guide
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Feb 15, 2024
1 parent 2db5b89 commit c1e3cff
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
22 changes: 15 additions & 7 deletions apps/app/src/lib/remote-player/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,22 @@ function notifyLogin() {
if (notified) return;
new Notice(
createFragment((e) => {
e.appendText("You're using a webpage media player");
e.createEl("p", { text: "To login to a website, use:" });
e.createEl("ul", {}, (ul) => {
ul.createEl("li", { text: 'the "Login" command' });
ul.createEl("li", { text: "the Settings tab" });
});
e.appendText("You're using a webpage media player.");
e.createEl(
"p",
{
text: "If you are requested to login, you can open a browser to login from:",
},
(p) => {
p.createEl("br");
p.appendText('- the "Login" command');
p.createEl("br");
p.appendText("- the entry in settings tab");
},
);
e.appendText("Click to dismiss this notice.");
}),
10e3,
0,
);
localStorage.setItem("mx:webview-login-notified", "1");
}
30 changes: 29 additions & 1 deletion apps/app/src/media-view/base.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import type { Component, Menu, View, ItemView } from "obsidian";
import {
type Component,
type Menu,
type View,
type ItemView,
Notice,
} from "obsidian";
import type ReactDOM from "react-dom/client";
import type { MediaViewStoreApi } from "@/components/context";
import { toURL } from "@/lib/url";
Expand Down Expand Up @@ -42,9 +48,30 @@ export function titleFromUrl(src: string): string {
}

export function addAction(player: PlayerComponent & ItemView) {
function noticeBehavior(action: string) {
const notified = localStorage.getItem("mx:media-notetaking-notice");
if (notified) return;
new Notice(
createFragment((e) => {
e.appendText(
`You are taking ${action} from media player. By default, they will only be saved in the media note. `,
);
e.createEl("p", {
text: `To take ${action} or control playback from abritrary note, use command when focused on the note`,
});
e.createEl("p", {
text: "PS: you can assign a hotkey to each command in the settings",
});
e.appendText("Click to dismiss this notice.");
}),
0,
);
localStorage.setItem("mx:media-noting-notice", "1");
}
player.addAction("star", "Timestamp", () => {
const info = player.getMediaInfo();
if (!info) return;
noticeBehavior("timestamp");
openOrCreateMediaNote(info, player).then((ctx) => {
takeTimestamp(player, ctx);
});
Expand All @@ -53,6 +80,7 @@ export function addAction(player: PlayerComponent & ItemView) {
player.addAction("camera", "Screenshot", () => {
const info = player.getMediaInfo();
if (!info) return;
noticeBehavior("screenshot");
openOrCreateMediaNote(info, player).then((ctx) =>
saveScreenshot(player, ctx),
);
Expand Down

0 comments on commit c1e3cff

Please sign in to comment.