mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-30 04:11:33 -08:00
fix: sometimes subwiki open is not triggered
This commit is contained in:
parent
16cb7de748
commit
b03a83853e
4 changed files with 12 additions and 18 deletions
|
|
@ -94,9 +94,15 @@ ipcRenderer.on(WikiChannel.generalNotification, async (event, message: string) =
|
|||
});
|
||||
// open a tiddler
|
||||
ipcRenderer.on(WikiChannel.openTiddler, async (event, tiddlerName: string) => {
|
||||
const newHref: string = await native.getLocalHostUrlWithActualIP(`http://localhost:5212/#${tiddlerName}`);
|
||||
// iterate until we find NavigatorWidget, this normally needs to be Widget > Widget > ElementWidget > TranscludeWidget > TranscludeWidget > ImportVariablesWidget > VarsWidget > ElementWidget > NavigatorWidget
|
||||
await executeTWJavaScriptWhenIdle(`
|
||||
window.location.href = "${newHref}";
|
||||
let currentHandlerWidget = $tw.rootWidget
|
||||
let handled = false;
|
||||
while (currentHandlerWidget && !handled) {
|
||||
const bubbled = currentHandlerWidget.dispatchEvent({ type: "tm-navigate", navigateTo: "${tiddlerName}", param: "${tiddlerName}" });
|
||||
handled = !bubbled;
|
||||
currentHandlerWidget = currentHandlerWidget.children?.[0]
|
||||
}
|
||||
`);
|
||||
});
|
||||
// send an action message
|
||||
|
|
|
|||
|
|
@ -49,15 +49,6 @@ export class Wiki implements IWikiService {
|
|||
return await getSubWikiPluginContent(mainWikiPath);
|
||||
}
|
||||
|
||||
public async requestOpenTiddlerInWiki(tiddlerName: string): Promise<void> {
|
||||
const browserViews = await this.viewService.getActiveBrowserViews();
|
||||
browserViews.forEach((browserView) => {
|
||||
if (browserView !== undefined) {
|
||||
browserView.webContents.send(WikiChannel.openTiddler, tiddlerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async requestWikiSendActionMessage(actionMessage: string): Promise<void> {
|
||||
const browserViews = await this.viewService.getActiveBrowserViews();
|
||||
browserViews.forEach((browserView) => {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ export interface IWikiService {
|
|||
openTiddlerInExternal(homePath: string, title: string): Promise<void>;
|
||||
packetHTMLFromWikiFolder(folderWikiPath: string, saveWikiHtmlfolder: string): Promise<void>;
|
||||
removeWiki(wikiPath: string, mainWikiToUnLink?: string, onlyRemoveLink?: boolean): Promise<void>;
|
||||
requestOpenTiddlerInWiki(tiddlerName: string): Promise<void>;
|
||||
/** send tiddlywiki action message to current active wiki */
|
||||
requestWikiSendActionMessage(actionMessage: string): Promise<void>;
|
||||
restartWiki(workspace: IWorkspace): Promise<void>;
|
||||
|
|
@ -89,7 +88,6 @@ export const WikiServiceIPCDescriptor = {
|
|||
linkWiki: ProxyPropertyType.Function,
|
||||
openTiddlerInExternal: ProxyPropertyType.Function,
|
||||
removeWiki: ProxyPropertyType.Function,
|
||||
requestOpenTiddlerInWiki: ProxyPropertyType.Function,
|
||||
requestWikiSendActionMessage: ProxyPropertyType.Function,
|
||||
restartWiki: ProxyPropertyType.Function,
|
||||
runFilterOnWiki: ProxyPropertyType.Function,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import type { IWikiGitWorkspaceService } from '@services/wikiGitWorkspace/interf
|
|||
import { IContextService } from '@services/context/interface';
|
||||
import { IGitService } from '@services/git/interface';
|
||||
import { SupportedStorageServices } from '@services/types';
|
||||
import { WikiChannel } from '@/constants/channels';
|
||||
|
||||
interface IWorkspaceMenuRequiredServices {
|
||||
auth: Pick<IAuthenticationService, 'getStorageServiceUserInfo'>;
|
||||
|
|
@ -19,7 +20,7 @@ interface IWorkspaceMenuRequiredServices {
|
|||
git: Pick<IGitService, 'commitAndSync'>;
|
||||
native: Pick<INativeService, 'open' | 'openInEditor' | 'openInGitGuiApp' | 'getLocalHostUrlWithActualIP'>;
|
||||
view: Pick<IViewService, 'reloadViewsWebContents' | 'getViewCurrentUrl'>;
|
||||
wiki: Pick<IWikiService, 'requestOpenTiddlerInWiki' | 'requestWikiSendActionMessage'>;
|
||||
wiki: Pick<IWikiService, 'wikiOperation' | 'requestWikiSendActionMessage'>;
|
||||
wikiGitWorkspace: Pick<IWikiGitWorkspaceService, 'removeWorkspace'>;
|
||||
window: Pick<IWindowService, 'open'>;
|
||||
workspace: Pick<IWorkspaceService, 'getActiveWorkspace'>;
|
||||
|
|
@ -45,12 +46,10 @@ export async function openWorkspaceTagTiddler(workspace: IWorkspace, service: IW
|
|||
// is not a new main workspace
|
||||
// open tiddler in the active view
|
||||
if (isSubWiki) {
|
||||
if (typeof tagName === 'string') {
|
||||
await service.wiki.requestOpenTiddlerInWiki(tagName);
|
||||
}
|
||||
if (mainWikiID === null || idToActive === undefined) {
|
||||
if (mainWikiID === null || idToActive === undefined || tagName === null) {
|
||||
return;
|
||||
}
|
||||
service.wiki.wikiOperation(WikiChannel.openTiddler, [mainWikiID, tagName]);
|
||||
idToActive = mainWikiID;
|
||||
} else {
|
||||
await service.wiki.requestWikiSendActionMessage('tm-home');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue