2021-04-27 15:35:35 -07:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
2022-06-16 20:48:57 -04:00
|
|
|
import type { LinkPreviewSourceType } from '../../types/LinkPreview';
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { StateType } from '../reducer';
|
2021-04-27 15:35:35 -07:00
|
|
|
|
|
|
|
export const getLinkPreview = createSelector(
|
2022-06-16 20:48:57 -04:00
|
|
|
({ linkPreviews }: StateType) => linkPreviews,
|
|
|
|
({ linkPreview, source }) => {
|
|
|
|
return (fromSource: LinkPreviewSourceType) => {
|
|
|
|
if (!linkPreview) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (source !== fromSource) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-04-23 16:08:55 -07:00
|
|
|
return linkPreview;
|
2022-06-16 20:48:57 -04:00
|
|
|
};
|
2021-04-27 15:35:35 -07:00
|
|
|
}
|
|
|
|
);
|