Skip to content

Commit 590f2f0

Browse files
committed
fixup! client: Add more type annotations
1 parent aef4f13 commit 590f2f0

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

client/js/sharers.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,35 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
33
import map from 'ramda/src/map.js';
44
import selfoss from './selfoss-base';
55
import * as icons from './icons';
6+
import { Configuration } from './model/Configuration';
67

7-
function materializeSharerIcon(sharer) {
8+
type Sharer = {
9+
label: string,
10+
icon: string | JSX.Element,
11+
action: (params: { url: string, title: string }) => void,
12+
available?: boolean,
13+
};
14+
15+
function materializeSharerIcon(sharer: Sharer): Sharer {
816
const { icon } = sharer;
917
return {
1018
...sharer,
19+
// We want to allow people to use <svg> or <img> in user.js
1120
icon: typeof icon === 'string' && icon.includes('<') ? <span dangerouslySetInnerHTML={{ __html: icon }} /> : icon,
1221
};
1322
}
1423

15-
export function useSharers({ configuration, _ }) {
24+
export function useSharers(
25+
args: {
26+
configuration: Configuration,
27+
_: (identifier: string, params?: {[index: string]: string}) => string,
28+
},
29+
): Array<Sharer> {
30+
const { configuration, _ } = args;
31+
1632
return useMemo(
17-
() => {
18-
const availableSharers = {
33+
(): Array<Sharer> => {
34+
const availableSharers: { [key: string]: Sharer } = {
1935
'a': {
2036
label: _('share_native_label'),
2137
icon: <FontAwesomeIcon icon={icons.share} />,

0 commit comments

Comments
 (0)