Files
outline/app/hooks/useEmbeds.ts
T
Tom MoorandClaude Opus 5.5 5647621224 chore: Prune redundant comments and type suppressions (#14124)
* chore: Prune redundant comments and normalize lint directives

Removes comments that restate the following line and stale TODOs, drops
the passive event listener feature check now that all supported browsers
support it, and renames eslint directives to oxlint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH

* fix: Evaluate restricted team domains at validation time

The restricted email provider list was captured when the model loaded, so
it could not follow the hosting environment and the tests that covered it
never reached the model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH

* chore: Replace type suppressions with accurate types

Adds a Concrete helper type for registries of abstract classes, declares
missing Sequelize and refractor typings, uses public ProseMirror APIs, a
typed mock context helper in middleware tests, and a StaticLink component
for sidebar rows being edited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BehTjuZwKbN5csMCp3H4QH

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-17 17:07:39 -04:00

59 lines
1.8 KiB
TypeScript

import { find } from "es-toolkit/compat";
import { useEffect, useMemo } from "react";
import { toError } from "@shared/utils/error";
import embeds from "@shared/editor/embeds";
import { IntegrationType, TeamPreference } from "@shared/types";
import type Integration from "~/models/Integration";
import Logger from "~/utils/Logger";
import useCurrentTeam from "./useCurrentTeam";
import useStores from "./useStores";
/**
* Hook to get all embed configuration for the current team
*
* @param loadIfMissing Should we load integration settings if they are not locally available
* @returns A list of embed descriptors
*/
export default function useEmbeds(loadIfMissing = false) {
const { integrations } = useStores();
const team = useCurrentTeam({ rejectOnEmpty: false });
useEffect(() => {
async function fetchEmbedIntegrations() {
try {
await integrations.fetchAll({
type: IntegrationType.Embed,
});
} catch (err) {
Logger.error("Failed to fetch embed integrations", toError(err));
}
}
if (!integrations.isLoaded && !integrations.isFetching && loadIfMissing) {
void fetchEmbedIntegrations();
}
}, [integrations, loadIfMissing]);
const disabledEmbeds =
(team?.getPreference(TeamPreference.DisabledEmbeds) as string[]) || [];
return useMemo(
() =>
embeds.map((e) => {
// Find any integrations that match this embed and inject the settings
const integration: Integration<IntegrationType.Embed> | undefined =
find(integrations.orderedData, (i) => i.service === e.name);
if (integration?.settings) {
e.settings = integration.settings;
}
e.disabled = disabledEmbeds.includes(e.id);
return e;
}),
// oxlint-disable-next-line react-hooks/exhaustive-deps
[integrations.orderedData, team?.preferences]
);
}