Skip to content

Commit

Permalink
Merge pull request #7 from Zuoqiu-Yingyi/dev
Browse files Browse the repository at this point in the history
chore: release v0.1.2
  • Loading branch information
Zuoqiu-Yingyi authored Aug 17, 2023
2 parents 122653b + baf56c5 commit 5eea405
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:

env:
PACKAGE_NAME: custom-fonts
PACKAGE_VERSION: 0.1.1
PACKAGE_VERSION: 0.1.2

jobs:
release-please:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wakatime",
"private": true,
"version": "0.1.1",
"version": "0.1.2",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion public/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wakatime",
"author": "Zuoqiu Yingyi",
"url": "https://github.com/Zuoqiu-Yingyi/siyuan-plugin-wakatime",
"version": "0.1.1",
"version": "0.1.2",
"minAppVersion": "2.9.9",
"backends": [
"all"
Expand Down
64 changes: 37 additions & 27 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import manifest from "~/public/plugin.json";

import {
Client,
KernelError,
type types,
} from "@siyuan-community/siyuan-sdk";

Expand Down Expand Up @@ -282,35 +283,44 @@ export default class WakaTimePlugin extends siyuan.Plugin {
}

/* 添加编辑事件 */
protected async addEditEvent(id: BlockID): Promise<Context.IRoot> {
const time = this.now;

/* 获取块对应的文档信息 */
let root_id = this.context.blocks.get(id);
let root_info = this.context.roots.get(root_id);
if (!root_info) {
const block_info = await this.client.getBlockInfo({ id });

root_id = block_info.data.rootID;
root_info = {
id: root_id,
box: block_info.data.box,
path: block_info.data.path,
events: [],
};
protected async addEditEvent(id: BlockID): Promise<Context.IRoot | null> {
try {
const time = this.now;

/* 获取块对应的文档信息 */
let root_id = this.context.blocks.get(id);
let root_info = this.context.roots.get(root_id);
if (!root_info) {
const block_info = await this.client.getBlockInfo({ id });
root_id = block_info.data.rootID;
root_info = {
id: root_id,
box: block_info.data.box,
path: block_info.data.path,
events: [],
};

this.context.blocks.set(id, root_id);
this.context.roots.set(root_id, root_info);
}

this.context.blocks.set(id, root_id);
this.context.roots.set(root_id, root_info);
/* 添加编辑事件 */
return this.addEvent({
id: root_info.id,
box: root_info.box,
path: root_info.path,
time,
is_write: true,
});
} catch (error) {
if (error instanceof KernelError) { // 块删除事件导致无法查询到对应的块
// this.logger.warn(error);
return;
}
else {
throw error;
}
}

/* 添加编辑事件 */
return this.addEvent({
id: root_info.id,
box: root_info.box,
path: root_info.path,
time,
is_write: true,
});
}

/* 添加查看事件 */
Expand Down

0 comments on commit 5eea405

Please sign in to comment.