Skip to content

Commit

Permalink
fix: context menu command not work
Browse files Browse the repository at this point in the history
  • Loading branch information
vipzhicheng committed May 7, 2022
1 parent e46b3ac commit 6be431b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v0.0.12

- fix: try to fix context menu command not work
## v0.0.11

- fix: try to fix console error.
Expand Down
5 changes: 4 additions & 1 deletion src/operations/moveTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { getSettings } from '@/common/funcs';

export default () => {
const keyBindings = getSettings('keyBindings');
const handler = async () => {
const handler = async ({ uuid }) => {
const targetStore = useTargetStore();
if (uuid) {
targetStore.setFallbackUUID(uuid);
}
targetStore.open();
logseq.showMainUI({
autoFocus: true,
Expand Down
13 changes: 12 additions & 1 deletion src/stores/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const processBlock = async (block: BlockEntity, destination: Destination) => {

export const useTargetStore = defineStore('target', {
state: () => ({
fallbackUUID: '',
visible: false,
destination: {
to: 'today',
Expand All @@ -144,6 +145,12 @@ export const useTargetStore = defineStore('target', {
pages: [],
}),
actions: {
setFallbackUUID(uuid: string) {
this.fallbackUUID = uuid;
},
clearFallbackUUID(uuid: string) {
this.fallbackUUID = '';
},
async loadPages() {
const pages = await logseq.DB.datascriptQuery(`
[:find ?page-name (pull ?page [*])
Expand Down Expand Up @@ -174,7 +181,10 @@ export const useTargetStore = defineStore('target', {
}
}
} else {
const block = await logseq.Editor.getCurrentBlock();
let block = await logseq.Editor.getCurrentBlock();
if (!block) {
block = await logseq.Editor.getBlock(this.fallbackUUID);
}
if (block) {
processed = await processBlock(block, this.destination);
if (!processed) {
Expand All @@ -190,6 +200,7 @@ export const useTargetStore = defineStore('target', {
}
}

this.clearFallbackUUID();
logseq.hideMainUI({
restoreEditingCursor: true,
});
Expand Down

0 comments on commit 6be431b

Please sign in to comment.