diff --git a/client/js/sharers.tsx b/client/js/sharers.tsx index cb2cfc7077..a1c7c71ac3 100644 --- a/client/js/sharers.tsx +++ b/client/js/sharers.tsx @@ -3,19 +3,35 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import map from 'ramda/src/map.js'; import selfoss from './selfoss-base'; import * as icons from './icons'; +import { Configuration } from './model/Configuration'; -function materializeSharerIcon(sharer) { +type Sharer = { + label: string, + icon: string | JSX.Element, + action: (params: { url: string, title: string }) => void, + available?: boolean, +}; + +function materializeSharerIcon(sharer: Sharer): Sharer { const { icon } = sharer; return { ...sharer, + // We want to allow people to use or in user.js icon: typeof icon === 'string' && icon.includes('<') ? : icon, }; } -export function useSharers({ configuration, _ }) { +export function useSharers( + args: { + configuration: Configuration, + _: (identifier: string, params?: {[index: string]: string}) => string, + }, +): Array { + const { configuration, _ } = args; + return useMemo( - () => { - const availableSharers = { + (): Array => { + const availableSharers: { [key: string]: Sharer } = { 'a': { label: _('share_native_label'), icon: ,