From 11a581e8a7fcb2b5d7a11f0253144c9e55838d8c Mon Sep 17 00:00:00 2001 From: Nevo David Date: Wed, 20 Mar 2024 13:12:36 +0700 Subject: [PATCH] feat: canonical link change + reddit change --- .../launches/providers/reddit/subreddit.tsx | 16 +++++++--------- .../post-url-selector/post.url.selector.tsx | 2 +- .../dtos/posts/providers-settings/reddit.dto.ts | 17 ++++++++--------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/apps/frontend/src/components/launches/providers/reddit/subreddit.tsx b/apps/frontend/src/components/launches/providers/reddit/subreddit.tsx index fb753d02..2a540c03 100644 --- a/apps/frontend/src/components/launches/providers/reddit/subreddit.tsx +++ b/apps/frontend/src/components/launches/providers/reddit/subreddit.tsx @@ -1,10 +1,4 @@ -import { - FC, - FormEvent, - useCallback, - useMemo, - useState, -} from 'react'; +import { FC, FormEvent, useCallback, useMemo, useState } from 'react'; import { useCustomProviderFunction } from '@gitroom/frontend/components/launches/helpers/use.custom.provider.function'; import { Input } from '@gitroom/react/form/input'; import { useDebouncedCallback } from 'use-debounce'; @@ -14,6 +8,8 @@ import { MultiMediaComponent } from '@gitroom/frontend/components/media/media.co import { useWatch } from 'react-hook-form'; import { Select } from '@gitroom/react/form/select'; import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values'; +import { Canonical } from '@gitroom/react/form/canonical'; +import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration'; export const RenderOptions: FC<{ options: Array<'self' | 'link' | 'media'>; @@ -60,6 +56,7 @@ export const Subreddit: FC<{ const { onChange, name } = props; const state = useSettings(); + const { date } = useIntegration(); const split = name.split('.'); const [loading, setLoading] = useState(false); // @ts-ignore @@ -225,7 +222,8 @@ export const Subreddit: FC<{ ))} {value.type === 'link' && ( - {!!results.length && !loading && ( -
+
{results.map((r: { id: string; name: string }) => (
-
+
e.type === 'link') @IsUrl() @IsDefined() + @ValidateIf((o) => o.type === 'link' && o?.url?.indexOf('(post:') === -1) + @Matches( + /^(|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})$/, + { + message: 'Invalid URL', + } + ) url: string; @IsBoolean()