macbook-pro-de-oscar.home 2026-1-13:14:27:8
This commit is contained in:
+64
-22
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// (disabled):register-scheme
|
||||
// (disabled):node_modules/register-scheme/index.js
|
||||
var require_register_scheme = __commonJS({
|
||||
"(disabled):register-scheme"() {
|
||||
"(disabled):node_modules/register-scheme/index.js"() {
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1162,6 +1162,8 @@ var DiscordRPCSettings = class {
|
||||
constructor() {
|
||||
this.showVaultName = true;
|
||||
this.showCurrentFileName = true;
|
||||
this.showFolderName = false;
|
||||
// ADD THIS LINE
|
||||
this.showConnectionTimer = false;
|
||||
this.showPopups = true;
|
||||
this.customVaultName = "";
|
||||
@@ -1183,7 +1185,7 @@ var DiscordRPCSettingsTab = class extends import_obsidian2.PluginSettingTab {
|
||||
this.logger = new Logger(plugin);
|
||||
}
|
||||
display() {
|
||||
let { containerEl } = this;
|
||||
const { containerEl } = this;
|
||||
const plugin = this.plugin;
|
||||
containerEl.empty();
|
||||
new import_obsidian2.Setting(containerEl).setName("Vault name").setHeading();
|
||||
@@ -1220,7 +1222,7 @@ var DiscordRPCSettingsTab = class extends import_obsidian2.PluginSettingTab {
|
||||
);
|
||||
})
|
||||
);
|
||||
new import_obsidian2.Setting(containerEl).setName("File name").setHeading();
|
||||
new import_obsidian2.Setting(containerEl).setName("File & Folder Name").setHeading();
|
||||
new import_obsidian2.Setting(containerEl).setName("Show current file name").setDesc("Enable this to show the name of the file you are working on.").addToggle(
|
||||
(boolean) => boolean.setValue(plugin.settings.showCurrentFileName).onChange((value) => {
|
||||
plugin.settings.showCurrentFileName = value;
|
||||
@@ -1232,6 +1234,17 @@ var DiscordRPCSettingsTab = class extends import_obsidian2.PluginSettingTab {
|
||||
);
|
||||
})
|
||||
);
|
||||
new import_obsidian2.Setting(containerEl).setName("Show folder name").setDesc("Enable this to show the folder path where the file is located.").addToggle(
|
||||
(boolean) => boolean.setValue(plugin.settings.showFolderName).onChange((value) => {
|
||||
plugin.settings.showFolderName = value;
|
||||
plugin.saveData(plugin.settings);
|
||||
plugin.setActivity(
|
||||
this.app.vault.getName(),
|
||||
plugin.currentFile.basename,
|
||||
plugin.currentFile.extension
|
||||
);
|
||||
})
|
||||
);
|
||||
new import_obsidian2.Setting(containerEl).setName("Show file extension").setDesc("Enable this to show file extension.").addToggle(
|
||||
(boolean) => boolean.setValue(plugin.settings.showFileExtension).onChange((value) => {
|
||||
plugin.settings.showFileExtension = value;
|
||||
@@ -1379,7 +1392,7 @@ var StatusBar = class _StatusBar {
|
||||
var ObsidianDiscordRPC = class extends import_obsidian4.Plugin {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.logger = new Logger();
|
||||
this.logger = new Logger(this);
|
||||
}
|
||||
setState(state) {
|
||||
this.state = state;
|
||||
@@ -1394,17 +1407,21 @@ var ObsidianDiscordRPC = class extends import_obsidian4.Plugin {
|
||||
return this.manifest;
|
||||
}
|
||||
async onload() {
|
||||
let statusBarEl = this.addStatusBarItem();
|
||||
const statusBarEl = this.addStatusBarItem();
|
||||
this.statusBar = new StatusBar(statusBarEl);
|
||||
this.settings = await this.loadData() || new DiscordRPCSettings();
|
||||
this.registerEvent(
|
||||
this.app.workspace.on("file-open", this.onFileOpen, this)
|
||||
);
|
||||
this.registerInterval(window.setInterval(async () => {
|
||||
if (this.settings.showConnectionTimer && this.getState() == 0 /* connected */) {
|
||||
this.statusBar.displayTimer(this.settings.useLoadedTime ? this.loadedTime : this.lastSetTime);
|
||||
}
|
||||
}, 500));
|
||||
this.registerInterval(
|
||||
window.setInterval(async () => {
|
||||
if (this.settings.showConnectionTimer && this.getState() == 0 /* connected */) {
|
||||
this.statusBar.displayTimer(
|
||||
this.settings.useLoadedTime ? this.loadedTime : this.lastSetTime
|
||||
);
|
||||
}
|
||||
}, 500)
|
||||
);
|
||||
this.registerDomEvent(statusBarEl, "click", async () => {
|
||||
if (this.getState() == 2 /* disconnected */) {
|
||||
await this.connectDiscord();
|
||||
@@ -1424,17 +1441,18 @@ var ObsidianDiscordRPC = class extends import_obsidian4.Plugin {
|
||||
callback: async () => await this.disconnectDiscord()
|
||||
});
|
||||
if (this.settings.connectOnStart) {
|
||||
await this.connectDiscord();
|
||||
const activeLeaf = this.app.workspace.activeLeaf;
|
||||
const files = this.app.vault.getMarkdownFiles();
|
||||
if (activeLeaf) {
|
||||
const displayText = activeLeaf.getDisplayText();
|
||||
files.forEach((file) => {
|
||||
if (file.basename === displayText) {
|
||||
this.onFileOpen(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.connectDiscord().then(() => {
|
||||
let view = this.app.workspace.getActiveViewOfType(import_obsidian4.MarkdownView);
|
||||
const files = this.app.vault.getMarkdownFiles();
|
||||
if (view) {
|
||||
const displayText = view.getDisplayText();
|
||||
files.forEach((file) => {
|
||||
if (file.basename === displayText) {
|
||||
this.onFileOpen(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.setState(2 /* disconnected */);
|
||||
this.statusBar.displayState(
|
||||
@@ -1502,6 +1520,7 @@ var ObsidianDiscordRPC = class extends import_obsidian4.Plugin {
|
||||
this.logger.log("Disconnected from Discord", this.settings.showPopups);
|
||||
}
|
||||
async setActivity(vaultName, fileName, fileExtension) {
|
||||
var _a;
|
||||
if (this.getState() === 0 /* connected */) {
|
||||
let vault;
|
||||
if (this.settings.customVaultName === "") {
|
||||
@@ -1515,6 +1534,13 @@ var ObsidianDiscordRPC = class extends import_obsidian4.Plugin {
|
||||
} else {
|
||||
file = fileName;
|
||||
}
|
||||
let folderPath = "";
|
||||
if (this.settings.showFolderName && this.currentFile) {
|
||||
const path = (_a = this.currentFile.parent) == null ? void 0 : _a.path;
|
||||
if (path && path !== "/") {
|
||||
folderPath = path;
|
||||
}
|
||||
}
|
||||
let date;
|
||||
if (this.settings.useLoadedTime) {
|
||||
date = this.loadedTime;
|
||||
@@ -1530,6 +1556,14 @@ var ObsidianDiscordRPC = class extends import_obsidian4.Plugin {
|
||||
largeImageKey: this.settings.themeStyle,
|
||||
largeImageText: "no info just privacy mode"
|
||||
});
|
||||
} else if (this.settings.showVaultName && this.settings.showCurrentFileName && this.settings.showFolderName && folderPath) {
|
||||
await this.rpc.setActivity({
|
||||
details: `Editing ${file}`,
|
||||
state: `Vault: ${vault} \u25B8 ${folderPath}`,
|
||||
startTimestamp: date,
|
||||
largeImageKey: this.settings.themeStyle,
|
||||
largeImageText: "I'm thinking!"
|
||||
});
|
||||
} else if (this.settings.showVaultName && this.settings.showCurrentFileName) {
|
||||
await this.rpc.setActivity({
|
||||
details: `Editing ${file}`,
|
||||
@@ -1538,6 +1572,14 @@ var ObsidianDiscordRPC = class extends import_obsidian4.Plugin {
|
||||
largeImageKey: this.settings.themeStyle,
|
||||
largeImageText: "I'm thinking!"
|
||||
});
|
||||
} else if (this.settings.showFolderName && folderPath && this.settings.showCurrentFileName) {
|
||||
await this.rpc.setActivity({
|
||||
details: `Editing: ${file}`,
|
||||
state: `Folder: ${folderPath}`,
|
||||
startTimestamp: date,
|
||||
largeImageKey: this.settings.themeStyle,
|
||||
largeImageText: "I'm thinking!"
|
||||
});
|
||||
} else if (this.settings.showVaultName) {
|
||||
await this.rpc.setActivity({
|
||||
state: `Vault: ${vault}`,
|
||||
|
||||
Reference in New Issue
Block a user