Skip to content

Commit

Permalink
Merge pull request #3921 from tloncorp/hm/generate-lures-for-non-hosts
Browse files Browse the repository at this point in the history
lure: make sure we generate a url if you aren't the one toggling
  • Loading branch information
arthyn authored Sep 16, 2024
2 parents 061130e + df8566c commit 09e7a07
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/tlon-web/src/state/lure/lure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
stringToTa,
} from '@/logic/utils';

import { useGroup } from '../groups';
import { useLocalState } from '../local';

interface LureMetadata {
Expand Down Expand Up @@ -211,6 +212,7 @@ const selLure = (flag: string) => (s: LureState) => ({
const { shouldLoad, newAttempt, finished } = getPreviewTracker(30 * 1000);
export function useLure(flag: string, disableLoading = false) {
const { bait, lure } = useLureState(selLure(flag));
const group = useGroup(flag);

useEffect(() => {
if (!bait || disableLoading || !shouldLoad(flag)) {
Expand Down Expand Up @@ -238,6 +240,12 @@ export function useLure(flag: string, disableLoading = false) {
[flag]
);

useEffect(() => {
if (lure.enabled && !lure.url && group?.meta) {
describe(group.meta);
}
}, [group]);

return {
...lure,
supported: bait,
Expand All @@ -262,7 +270,7 @@ export function useLureLinkChecked(url: string, enabled: boolean) {
prevData.current ?? false
),
{
enabled,
enabled: enabled && !!url,
refetchInterval: 5000,
}
);
Expand Down

0 comments on commit 09e7a07

Please sign in to comment.