All files / core/blong-browser/src/feedback useFeedbackConfig.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                                      25x 87x 25x 25x    
/**
 * useFeedbackConfig.ts — where the mode's wiring comes from (`@@T-467`).
 *
 * Two sources, in order: the portal config the browser was started with
 * (`config.portal.feedback`, which is where a suite writes it) and the config the
 * server composed for the menu (`portal.portalConfig.feedback`). A suite normally
 * writes the first; the second exists so a deployment can ship the block with the
 * rest of its portal configuration.
 *
 * Reading both matters: the composed config is a menu document and does not carry
 * everything a suite declares statically, so a switch that only looked at it would
 * never appear.
 */
 
import {useBlong, type IBlongPortalConfig} from '../context/BlongContext.js';
import {useAppStore} from '../state/appStore.js';
import type {IPortalFeedbackConfig} from '../types/portal.js';
 
export function useFeedbackConfig(): IPortalFeedbackConfig | undefined {
    const {config} = useBlong();
    const composed = useAppStore(state => state.portal.portalConfig?.feedback);
    const declared = (config as {portal?: IBlongPortalConfig}).portal?.feedback;
    return declared ?? composed;
}