Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

1.4 KB
Raw Blame
export const shouldRenderBacklinkResponse = (refreshQueued: boolean, searchQueued: boolean) => {
    return !refreshQueued && !searchQueued;
};

export const shouldSaveBacklinkStatus = (init: boolean, showingLoading: boolean) => {
    return !init && !showingLoading;
};

export const shouldDeferBottomBacklinkRefresh = (panelFocused: boolean, ignoreFocus: boolean) => {
    return panelFocused && !ignoreFocus;
};

export const getBottomBacklinkVisibility = (
    linkRefsCount: number,
    mentionsCount: number,
    backlinkKeyword: string,
    mentionKeyword: string,
    sourceFilterActive = false,
) => {
    const hideBacklinks = linkRefsCount === 0 && !backlinkKeyword && !sourceFilterActive;
    const hideMentions = mentionsCount === 0 && !mentionKeyword;
    return {
        hideBacklinks,
        hideMentions,
        hidePanel: hideBacklinks && hideMentions,
    };
};

export const getInitialBacklinkSectionState = (expandCount: number, ids: string[]) => {
    return {
        folded: expandCount === -1,
        openIds: expandCount > 0 ? ids.slice(0, expandCount) : [],
    };
};

export const shouldRefreshAllBacklinkContexts = (
    rootIDs: Set<string>,
    targetRootID: string,
    blockID: string,
    explicit: boolean,
    queryChanged: boolean,
    full: boolean,
) => {
    return explicit || queryChanged || full || rootIDs.has(targetRootID) || rootIDs.has(blockID);
};