channels: add useAtelierRefresh, for the atelier plugin's Generate/Gallery panels
same stable-bump shape as useFilesRefresh. Generate and Gallery are independent sibling panels with no props between them (per the panel contract, components only ever receive panelId), so a finished job reaching the gallery needs a signal rather than the standalone app's onFinished callback prop.
This commit is contained in:
@@ -97,3 +97,20 @@ export const useBackgroundJobChanged = () => {
|
||||
const bump = useCallback(() => setRef.current(++nonce), []);
|
||||
return [signal, bump] as const;
|
||||
};
|
||||
|
||||
/**
|
||||
* "A generation finished — anyone showing the gallery should re-read."
|
||||
*
|
||||
* The Generate and Gallery panels are independent siblings (see `plugins/atelier/web/panels.ts`) with
|
||||
* no props between them, so a finished job reaching the gallery needs a signal rather than a callback
|
||||
* prop the way the standalone app's `onFinished` was. Same stable-bump shape as `useFilesRefresh`.
|
||||
*/
|
||||
const useAtelierRefreshChannel = defineChannel<number>('atelier:refresh-signal', 0);
|
||||
|
||||
export const useAtelierRefresh = () => {
|
||||
const [signal, setSignal] = useAtelierRefreshChannel();
|
||||
const setRef = useRef(setSignal);
|
||||
setRef.current = setSignal;
|
||||
const bump = useCallback(() => setRef.current(++nonce), []);
|
||||
return [signal, bump] as const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user