Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Data/constants.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ export enum ServiceName {
HackerNews = 'Hacker News',
}

export const standardNaming: { [key: string]: string } = {
x: ServiceName.X,
email: ServiceName.Email,
gmail: ServiceName.Gmail,
reddit: ServiceName.Reddit,
trello: ServiceName.Trello,
blogger: ServiceName.Blogger,
yahoo_mail: ServiceName.Yahoo,
telegram: ServiceName.Telegram,
whatsapp: ServiceName.Whatsapp,
facebook: ServiceName.Facebook,
linkedin: ServiceName.Linkedin,
custom_share: ServiceName.Custom,
hacker_news: ServiceName.HackerNews,
};

export enum SharingMode {
Direct = 'direct',
Indirect = 'indirect',
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Store/slices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const reducers = combineReducers({
storage,
key: 'storage',
keyPrefix: `${CONFIG.APP_SHORT_NAME}-`,
blacklist: ['openShareModal', 'activePage'],
blacklist: ['shareModal', 'activePage'],
transforms: [compressor] as any,
},
LocalCacheReducer.reducer
Expand Down
3 changes: 3 additions & 0 deletions src/Tools/Utils/Standardize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const toStandardName = (service_name: string) => {
return service_name.toLowerCase().replace(' ', '_');
};
4 changes: 3 additions & 1 deletion src/Views/Layout/ShareModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useLocalCache, setShareModal } from '@src/Tools/Store/slices/LocalCache
import { Checkbox, CheckboxGroup, Col, Modal, Radio, RadioGroup, Row, Tooltip, Whisper } from 'rsuite';
import { useData } from '@src/Tools/Hooks/useData';
import { ServiceName } from '@src/Data/constants.data';
import { toStandardName } from '@src/Tools/Utils/Standardize';

const ShareModal = () => {
const { dispatch } = useStore();
Expand Down Expand Up @@ -38,7 +39,8 @@ const ShareModal = () => {
};

const getShareLink = (service_title: string, url: string) => {
const path = `?path=share&service=${service_title}&subject=${temp.subject}&link=${url}`;
const serviceName = toStandardName(service_title);
const path = `?path=share&service=${serviceName}&subject=${temp.subject}&link=${url}`;
if (temp.encodingValue?.length) {
const encoded_path = encode(path);
return `${CONFIG.FRONT_DOMAIN}/?encoded=${encoded_path}`;
Expand Down
11 changes: 4 additions & 7 deletions src/Views/Pages/GetButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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';
import { toStandardName } from '@src/Tools/Utils/Standardize';

const GetButton = () => {
const { isMobile } = useWindow();
Expand Down Expand Up @@ -49,7 +50,8 @@ const GetButton = () => {
};

const getShareLink = (service_title: string, url: string) => {
const path = `?path=share&service=${service_title}&subject=${temp.subject}&link=${url}`;
const serviceName = toStandardName(service_title);
const path = `?path=share&service=${serviceName}&subject=${temp.subject}&link=${url}`;
if (!!temp.encodingValue?.[0]) {
const encoded_path = encode(path);
return `${CONFIG.FRONT_DOMAIN}/?encoded=${encoded_path}`;
Expand Down Expand Up @@ -262,12 +264,7 @@ const GetButton = () => {
const checked = selectedServices.includes(service.title);
return (
<Col xs={12} sm={8} key={i}>
<Service
{...service}
checked={checked}
onSelect={onAddService}
onRemove={onRemoveService}
/>
<Service {...service} checked={checked} onSelect={onAddService} onRemove={onRemoveService} />
</Col>
);
})}
Expand Down
5 changes: 4 additions & 1 deletion src/Views/Pages/Share/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useLocation } from 'react-router-dom';
import LoadingCover from '@src/Components/LoadingCover';
import { getServiceURL } from '@src/Data/services.data';
import { decode } from '@src/Tools/Utils/URLEncoding';
import { toStandardName } from '@src/Tools/Utils/Standardize';
import { standardNaming } from '@data/constants.data';

const Share = () => {
const location = useLocation();
Expand All @@ -18,7 +20,8 @@ const Share = () => {
const subject = urlParams.get('subject') || '';
const link = urlParams.get('link') || '';

const url = getServiceURL(encodeURIComponent(link), subject)[service];
const serviceName = standardNaming[toStandardName(service)];
const url = getServiceURL(encodeURIComponent(link), subject)[serviceName];
setTimeout(() => {
window.open(url, '_self');
}, 100);
Expand Down