Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingislost committed Sep 10, 2021
1 parent a12f9b0 commit 722f562
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
34 changes: 20 additions & 14 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ export default class WorkspacePicker extends Plugin {

// add the settings tab
this.addSettingTab(new WorkspacePickerSettingsTab(this.app, this));

const workspacePickerStatusBarItem = this.addStatusBarItem();

this.workspacePlugin = this.app.internalPlugins.getPluginById("workspaces").instance as WorkspacePluginInstance;

const icon = workspacePickerStatusBarItem.createSpan("status-bar-item-segment icon");
setIcon(icon, "pane-layout"); //pane-layout

this.changeWorkspaceButton = workspacePickerStatusBarItem.createSpan({
cls: "status-bar-item-segment name",
text: this.workspacePlugin.activeWorkspace + (this.isWorkspaceModified() ? "*" : ""),
prepend: false,
});
setTimeout(() => { // TODO: dirty hack to delay load and make sure our icon is always in the bottom right
const workspacePickerStatusBarItem = this.addStatusBarItem();
workspacePickerStatusBarItem.addClass('mod-clickable')
const icon = workspacePickerStatusBarItem.createSpan("status-bar-item-segment icon mod-clickable");
setIcon(icon, "pane-layout"); //pane-layout

this.changeWorkspaceButton = workspacePickerStatusBarItem.createSpan({
cls: "status-bar-item-segment name",
text: this.workspacePlugin.activeWorkspace + (this.isWorkspaceModified() ? "*" : ""),
prepend: false,
});
workspacePickerStatusBarItem.addEventListener("click", () => {
new WorkspacePickerPluginModal(this.app, this.settings).open();
});
}, 100);

this.registerEvent(this.app.workspace.on("layout-change", this.updateWorkspaceName));

this.registerEvent(this.app.workspace.on("resize", this.updateWorkspaceName));

this.changeWorkspaceButton.addEventListener("click", () => {
new WorkspacePickerPluginModal(this.app, this.settings).open();
});


this.addCommand({
id: "open-workspace-picker",
Expand All @@ -43,7 +47,9 @@ export default class WorkspacePicker extends Plugin {
}

updateWorkspaceName = () => {
this.changeWorkspaceButton.setText(this.workspacePlugin.activeWorkspace + (this.isWorkspaceModified() ? "*" : ""));
setTimeout(() => {
this.changeWorkspaceButton.setText(this.workspacePlugin.activeWorkspace + (this.isWorkspaceModified() ? "*" : ""));
}, 100);
};

isWorkspaceModified = () => {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "workspace-picker",
"name": "Workspace Picker",
"version": "0.0.6",
"version": "0.0.7",
"minAppVersion": "0.9.12",
"description": "Quickly switch and manage workspaces",
"author": "NothingIsLost",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-workspace-picker",
"version": "0.0.6",
"version": "0.0.7",
"description": "Quickly switch and manage workspaces",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
vertical-align: text-top;
}

.workspace-picker-modal .workspace-item[contenteditable="true"] {
.workspace-picker-modal .workspace-item[contenteditable="true"]:focus {
cursor: text;
border: 1px solid #777;
border-radius: 6px;
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.0.7": "0.9.12",
"0.0.6": "0.9.12",
"0.0.5": "0.9.12",
"0.0.4": "0.9.12",
Expand Down

0 comments on commit 722f562

Please sign in to comment.