streak start mobile mvp
This commit is contained in:
parent
eca2978fc2
commit
cdbdcd2ac8
|
@ -15,6 +15,7 @@ import {
|
||||||
selectComposeSuggestion,
|
selectComposeSuggestion,
|
||||||
uploadCompose,
|
uploadCompose,
|
||||||
} from 'soapbox/actions/compose.ts';
|
} from 'soapbox/actions/compose.ts';
|
||||||
|
import { openModal } from 'soapbox/actions/modals.ts';
|
||||||
import { useCustomEmojis } from 'soapbox/api/hooks/useCustomEmojis.ts';
|
import { useCustomEmojis } from 'soapbox/api/hooks/useCustomEmojis.ts';
|
||||||
import AutosuggestInput, { AutoSuggestion } from 'soapbox/components/autosuggest-input.tsx';
|
import AutosuggestInput, { AutoSuggestion } from 'soapbox/components/autosuggest-input.tsx';
|
||||||
import Button from 'soapbox/components/ui/button.tsx';
|
import Button from 'soapbox/components/ui/button.tsx';
|
||||||
|
@ -72,9 +73,10 @@ interface IComposeForm<ID extends string> {
|
||||||
event?: string;
|
event?: string;
|
||||||
group?: string;
|
group?: string;
|
||||||
extra?: React.ReactNode;
|
extra?: React.ReactNode;
|
||||||
|
streak?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickableAreaRef, event, group, extra }: IComposeForm<ID>) => {
|
const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickableAreaRef, event, group, extra, streak }: IComposeForm<ID>) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
@ -156,6 +158,10 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
||||||
dispatch(changeCompose(id, text));
|
dispatch(changeCompose(id, text));
|
||||||
dispatch(submitCompose(id, { history }));
|
dispatch(submitCompose(id, { history }));
|
||||||
|
|
||||||
|
if (streak) {
|
||||||
|
dispatch(openModal('STREAK'));
|
||||||
|
}
|
||||||
|
|
||||||
editorRef.current?.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
|
editorRef.current?.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import {
|
||||||
ReblogsModal,
|
ReblogsModal,
|
||||||
ReplyMentionsModal,
|
ReplyMentionsModal,
|
||||||
ReportModal,
|
ReportModal,
|
||||||
|
StreakModal,
|
||||||
UnauthorizedModal,
|
UnauthorizedModal,
|
||||||
VideoModal,
|
VideoModal,
|
||||||
EditRuleModal,
|
EditRuleModal,
|
||||||
|
@ -92,6 +93,7 @@ const MODAL_COMPONENTS: Record<string, React.ExoticComponent<any>> = {
|
||||||
'REBLOGS': ReblogsModal,
|
'REBLOGS': ReblogsModal,
|
||||||
'REPLY_MENTIONS': ReplyMentionsModal,
|
'REPLY_MENTIONS': ReplyMentionsModal,
|
||||||
'REPORT': ReportModal,
|
'REPORT': ReportModal,
|
||||||
|
'STREAK': StreakModal,
|
||||||
'UNAUTHORIZED': UnauthorizedModal,
|
'UNAUTHORIZED': UnauthorizedModal,
|
||||||
'VIDEO': VideoModal,
|
'VIDEO': VideoModal,
|
||||||
'ZAPS': ZapsModal,
|
'ZAPS': ZapsModal,
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts';
|
||||||
import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts';
|
import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts';
|
||||||
import { useCompose } from 'soapbox/hooks/useCompose.ts';
|
import { useCompose } from 'soapbox/hooks/useCompose.ts';
|
||||||
import { useDraggedFiles } from 'soapbox/hooks/useDraggedFiles.ts';
|
import { useDraggedFiles } from 'soapbox/hooks/useDraggedFiles.ts';
|
||||||
|
import { useOwnAccount } from 'soapbox/hooks/useOwnAccount.ts';
|
||||||
|
|
||||||
import ComposeForm from '../../../compose/components/compose-form.tsx';
|
import ComposeForm from '../../../compose/components/compose-form.tsx';
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ const ComposeModal: React.FC<IComposeModal> = ({ onClose, composeId = 'compose-m
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const node = useRef<HTMLDivElement>(null);
|
const node = useRef<HTMLDivElement>(null);
|
||||||
const compose = useCompose(composeId);
|
const compose = useCompose(composeId);
|
||||||
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const { id: statusId, privacy, in_reply_to: inReplyTo, quote, group_id: groupId } = compose!;
|
const { id: statusId, privacy, in_reply_to: inReplyTo, quote, group_id: groupId } = compose!;
|
||||||
|
|
||||||
|
@ -40,6 +42,8 @@ const ComposeModal: React.FC<IComposeModal> = ({ onClose, composeId = 'compose-m
|
||||||
dispatch(uploadCompose(composeId, files, intl));
|
dispatch(uploadCompose(composeId, files, intl));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const userStreak = useAppSelector((state) => account?.ditto?.streak?.days ?? 0);
|
||||||
|
|
||||||
const onClickClose = () => {
|
const onClickClose = () => {
|
||||||
if (checkComposeContent(compose)) {
|
if (checkComposeContent(compose)) {
|
||||||
dispatch(openModal('CONFIRM', {
|
dispatch(openModal('CONFIRM', {
|
||||||
|
@ -93,6 +97,7 @@ const ComposeModal: React.FC<IComposeModal> = ({ onClose, composeId = 'compose-m
|
||||||
id={composeId}
|
id={composeId}
|
||||||
extra={<ComposeFormGroupToggle composeId={composeId} groupId={groupId} />}
|
extra={<ComposeFormGroupToggle composeId={composeId} groupId={groupId} />}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
streak={userStreak}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@ -135,4 +140,4 @@ const ComposeFormGroupToggle: React.FC<IComposeFormGroupToggle> = ({ composeId,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ComposeModal;
|
export default ComposeModal;
|
|
@ -0,0 +1,22 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
import Modal from 'soapbox/components/ui/modal.tsx';
|
||||||
|
import Text from 'soapbox/components/ui/text.tsx';
|
||||||
|
|
||||||
|
interface IStreakModal {
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StreakModal: React.FC<IStreakModal> = ({ onClose }) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal title={<FormattedMessage id='streak_modal.title' defaultMessage="You've started a new streak!" />} onClose={onClose}>
|
||||||
|
<Text>
|
||||||
|
<FormattedMessage id='streak_modal.message' defaultMessage='Post every day to keep it going!' />
|
||||||
|
</Text>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StreakModal;
|
|
@ -181,3 +181,4 @@ export const ZapsModal = lazy(() => import('soapbox/features/ui/components/modal
|
||||||
export const ZapSplitModal = lazy(() => import('soapbox/features/ui/components/modals/zap-split/zap-split-modal.tsx'));
|
export const ZapSplitModal = lazy(() => import('soapbox/features/ui/components/modals/zap-split/zap-split-modal.tsx'));
|
||||||
export const CaptchaModal = lazy(() => import('soapbox/features/ui/components/modals/captcha-modal/captcha-modal.tsx'));
|
export const CaptchaModal = lazy(() => import('soapbox/features/ui/components/modals/captcha-modal/captcha-modal.tsx'));
|
||||||
export const NostrBunkerLogin = lazy(() => import('soapbox/features/nostr/nostr-bunker-login.tsx'));
|
export const NostrBunkerLogin = lazy(() => import('soapbox/features/nostr/nostr-bunker-login.tsx'));
|
||||||
|
export const StreakModal = lazy(() => import('soapbox/features/ui/components/modals/streak-modal.tsx'));
|
||||||
|
|
Loading…
Reference in New Issue