dispatch(setOpenShareModal(true))}>
+
dispatch(setShareModal({ open: true }))}>
Share
{
const { dispatch } = useStore();
- const urlParams = useSearchParams()[0];
- const path = urlParams.get('path');
- const { openShareModal } = useLocalCache();
+ const { shareModal } = useLocalCache();
const { set, temp, discard } = useData(
{
- url: path === 'custom_share' ? urlParams.get('link') || '' : '',
- subject: path === 'custom_share' ? urlParams.get('subject') || '' : '',
+ url: shareModal.url || '',
+ subject: shareModal.subject || '',
isValid: true,
encodingValue: [],
shareMode: 'direct',
},
- [urlParams]
+ [shareModal]
);
// ? ------------------------- Functions -----------------------
@@ -56,10 +54,10 @@ const ShareModal = () => {
// --------------------------------------------------------------
return (
{
- dispatch(setOpenShareModal(false));
+ dispatch(setShareModal({ open: false }));
discard();
}}
backdrop
@@ -122,7 +120,7 @@ const ShareModal = () => {
- {SERVICES.map((service, i) => {
+ {SERVICES.filter(s => s.title !== ServiceName.Custom).map((service, i) => {
const validated_url = urlValidation(temp.url);
const href =
temp.shareMode === 'direct'
diff --git a/src/Views/Layout/index.tsx b/src/Views/Layout/index.tsx
index d81313c..fac4147 100644
--- a/src/Views/Layout/index.tsx
+++ b/src/Views/Layout/index.tsx
@@ -6,21 +6,21 @@ import ShareModal from './ShareModal';
import PagesRouter from '../Pages/PagesRouter';
import useStore from '@src/Tools/Store/useStore';
import { useSearchParams } from 'react-router-dom';
-import { ReactComponent as Bg } from '@assets/Images/bg.svg';
-import { setActivePage, setOpenShareModal } from '@src/Tools/Store/slices/LocalCacheSlice';
import { decode } from '@src/Tools/Utils/URLEncoding';
+import { ReactComponent as Bg } from '@assets/Images/bg.svg';
+import { setActivePage, setShareModal } from '@src/Tools/Store/slices/LocalCacheSlice';
const Layout = () => {
const urlParams = useSearchParams()[0];
const encoded = urlParams.get('encoded');
- const path = urlParams.get('path') || new URLSearchParams(decode(encoded || '')).get('path');
+ const paramsString = encoded ? new URLSearchParams(decode(encoded || '')) : urlParams;
+ const path = paramsString.get('path');
const { dispatch } = useStore();
useEffect(() => {
- dispatch(setActivePage(path));
if (path === 'custom_share') {
- dispatch(setOpenShareModal(true));
- }
+ dispatch(setShareModal({ open: true, url: paramsString.get('link'), subject: paramsString.get('subject') }));
+ } else dispatch(setActivePage(path));
}, [path]);
return (
diff --git a/src/Views/Pages/GetButton/index.scss b/src/Views/Pages/GetButton/index.scss
index 814a8ef..6e8e2c0 100644
--- a/src/Views/Pages/GetButton/index.scss
+++ b/src/Views/Pages/GetButton/index.scss
@@ -159,7 +159,7 @@
@apply overflow-y-auto;
.rs-col {
- @apply sm:mb-2;
+ @apply sm:mb-2 p-0;
}
.service-radio {
@@ -196,7 +196,10 @@
}
h2 {
- @apply ml-1.5 capitalize transition-colors;
+ @apply ml-1.5 transition-colors;
+ @include down(md) {
+ font-size: 0.75rem;
+ }
}
}
}
diff --git a/src/Views/Pages/GetButton/index.tsx b/src/Views/Pages/GetButton/index.tsx
index 47e5435..02a3244 100644
--- a/src/Views/Pages/GetButton/index.tsx
+++ b/src/Views/Pages/GetButton/index.tsx
@@ -2,15 +2,18 @@ import './index.scss';
import { useEffect, useState } from 'react';
import Service from '@src/Components/Service';
import { ValueType } from 'rsuite/esm/Checkbox';
+import useStore from '@src/Tools/Store/useStore';
import useWindow from '@src/Tools/Hooks/useWindow';
import { useData } from '@src/Tools/Hooks/useData';
import { CONFIG } from '@src/App/Config/constants';
import { classes } from '../../../Tools/Utils/React';
import { encode } from '@src/Tools/Utils/URLEncoding';
+import { ServiceName, SharingMode } from '@src/Data/constants.data';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { copyToClipboard } from '@src/Tools/Utils/React';
import { SERVICES, getServiceURL } from '@src/Data/services.data';
import EditableInput from '@src/Components/EditableInput/EditableInput';
+import { setShareModal } from '@src/Tools/Store/slices/LocalCacheSlice';
import { lightfair } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import { ReactComponent as Clone } from '@assets/icons/clone-regular.svg';
import { Button, Checkbox, CheckboxGroup, Col, Modal, Radio, RadioGroup, Row, Tooltip, Whisper } from 'rsuite';
@@ -18,6 +21,7 @@ import { Button, Checkbox, CheckboxGroup, Col, Modal, Radio, RadioGroup, Row, To
const GetButton = () => {
const { isMobile } = useWindow();
const [buttons, setButtons] = useState();
+ const { dispatch } = useStore();
const { set, temp } = useData({
url: '',
code: '',
@@ -26,12 +30,13 @@ const GetButton = () => {
showCode: false,
openModal: false,
openTooltip: false,
- shareMode: 'direct',
+ shareMode: SharingMode.Direct,
whisperOpen: false,
dropdownOpen: false,
encodingValue: [],
});
- const [selectedServices, setSelectedServices] = useState(['Email']);
+ const [selectedServices, setSelectedServices] = useState([ServiceName.Email]);
+ const services = temp.shareMode === SharingMode.Indirect ? SERVICES : SERVICES.filter(s => s.title !== ServiceName.Custom);
// ? -------------------------- Functions ------------------------------
const onAddService = (title: string) => {
@@ -71,7 +76,18 @@ const GetButton = () => {
{selected.map((service, i) => {
const href = temp.shareMode === 'direct' ? urls[service.title] : getShareLink(service.title, validated_url);
return (
-
+ {
+ openShareModal(e, temp.url);
+ },
+ }
+ : {})}
+ target='_blank'
+ rel='noreferrer'
+ key={i}>
{
else set.ou.temp('encodingValue', []);
};
+ const openShareModal = (e: any, url: string) => {
+ e.preventDefault();
+ dispatch(setShareModal({ open: true, url, subject: temp.subject }));
+ };
+
// ? ------------------------------ useEffect -------------------------------
useEffect(() => {
if (temp.showCode) getCode();
- }, [selectedServices, temp.shareMode, temp.encodingValue]);
+ }, [selectedServices, temp.shareMode, temp.encodingValue.length]);
// --------------------------------------------------------------------------
return (
@@ -168,14 +189,14 @@ const GetButton = () => {
defaultValue={temp.shareMode}
onChange={value => set.ou.temp('shareMode', value)}>
- Direct
- Indirect
+ Direct
+ Indirect
@@ -237,7 +258,7 @@ const GetButton = () => {
- {SERVICES.map((service, i) => {
+ {services.map((service, i) => {
const checked = selectedServices.includes(service.title);
return (