Skip to content

Commit

Permalink
enhance(plugin): app proxy call
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 committed Jan 6, 2025
1 parent 87e01f1 commit 25adb80
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions libs/src/LSPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export interface AppUserInfo {

export interface AppInfo {
version: string
supportDb: boolean

[key: string]: unknown
}
Expand Down
9 changes: 7 additions & 2 deletions libs/src/LSPlugin.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ export class LSPluginUser

return function (this: any, ...args: any) {
if (origMethod) {
const ret = origMethod.apply(that, args.concat(tag))
if (args?.length !== 0) args.concat(tag)
const ret = origMethod.apply(that, args)
if (ret !== PROXY_CONTINUE) return ret
}

Expand Down Expand Up @@ -817,11 +818,15 @@ export class LSPluginUser
return this._execCallableAPIAsync(`_callMainWin`, ...args)
}

// User Proxies
#appProxy: IAppProxy

/**
* The interface methods of {@link IAppProxy}
*/
get App (): IAppProxy {
return this._makeUserProxy(app, 'app')
if (this.#appProxy) return this.#appProxy
return (this.#appProxy = this._makeUserProxy(app, 'app'))
}

get Editor (): IEditorProxy {
Expand Down
7 changes: 4 additions & 3 deletions src/main/logseq/api.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@
(defn ^:export get_app_info
;; get app base info
[]
(bean/->js
(sdk-utils/normalize-keyword-for-json
{:version fv/version})))
(-> (sdk-utils/normalize-keyword-for-json
{:version fv/version
:supportDb true})
(bean/->js)))

(def ^:export get_user_configs
(fn []
Expand Down

0 comments on commit 25adb80

Please sign in to comment.