From cdbb88d2e03b5024bf56b6f0f320de5d3daf750c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 12 Jun 2022 16:14:46 +0200 Subject: [PATCH 1/4] TypeScript, React.FC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/components/ui/modal/modal.tsx | 2 +- .../compose/components/reply_indicator.tsx | 6 +- .../components/crypto_address.tsx | 2 +- .../components/scheduled_status.tsx | 4 +- .../features/ui/components/boost_modal.js | Bin 2272 -> 0 bytes .../features/ui/components/boost_modal.tsx | 48 ++++++++++ .../ui/components/confirmation_modal.js | Bin 2293 -> 0 bytes .../ui/components/confirmation_modal.tsx | 82 ++++++++++++++++++ .../ui/components/crypto_donate_modal.js | Bin 543 -> 0 bytes .../ui/components/crypto_donate_modal.tsx | 16 ++++ .../features/ui/components/list_panel.js | Bin 1486 -> 0 bytes .../features/ui/components/list_panel.tsx | 45 ++++++++++ .../features/ui/components/mute_modal.js | Bin 3106 -> 0 bytes .../features/ui/components/mute_modal.tsx | 77 ++++++++++++++++ .../features/ui/components/pending_status.tsx | 4 +- .../features/ui/components/poll_preview.js | Bin 1229 -> 0 bytes .../features/ui/components/poll_preview.tsx | 44 ++++++++++ app/soapbox/reducers/{mutes.js => mutes.ts} | Bin 764 -> 926 bytes 18 files changed, 321 insertions(+), 9 deletions(-) delete mode 100644 app/soapbox/features/ui/components/boost_modal.js create mode 100644 app/soapbox/features/ui/components/boost_modal.tsx delete mode 100644 app/soapbox/features/ui/components/confirmation_modal.js create mode 100644 app/soapbox/features/ui/components/confirmation_modal.tsx delete mode 100644 app/soapbox/features/ui/components/crypto_donate_modal.js create mode 100644 app/soapbox/features/ui/components/crypto_donate_modal.tsx delete mode 100644 app/soapbox/features/ui/components/list_panel.js create mode 100644 app/soapbox/features/ui/components/list_panel.tsx delete mode 100644 app/soapbox/features/ui/components/mute_modal.js create mode 100644 app/soapbox/features/ui/components/mute_modal.tsx delete mode 100644 app/soapbox/features/ui/components/poll_preview.js create mode 100644 app/soapbox/features/ui/components/poll_preview.tsx rename app/soapbox/reducers/{mutes.js => mutes.ts} (50%) diff --git a/app/soapbox/components/ui/modal/modal.tsx b/app/soapbox/components/ui/modal/modal.tsx index f0a6612291..3b2ba89e97 100644 --- a/app/soapbox/components/ui/modal/modal.tsx +++ b/app/soapbox/components/ui/modal/modal.tsx @@ -27,7 +27,7 @@ interface IModal { /** Callback when the modal is cancelled. */ cancelAction?: () => void, /** Cancel button text. */ - cancelText?: string, + cancelText?: React.ReactNode, /** URL to an SVG icon for the close button. */ closeIcon?: string, /** Position of the close button. */ diff --git a/app/soapbox/features/compose/components/reply_indicator.tsx b/app/soapbox/features/compose/components/reply_indicator.tsx index d135bfdeb0..f47b0494bd 100644 --- a/app/soapbox/features/compose/components/reply_indicator.tsx +++ b/app/soapbox/features/compose/components/reply_indicator.tsx @@ -9,13 +9,13 @@ import type { Status } from 'soapbox/types/entities'; interface IReplyIndicator { status?: Status, - onCancel: () => void, + onCancel?: () => void, hideActions: boolean, } const ReplyIndicator: React.FC = ({ status, hideActions, onCancel }) => { const handleClick = () => { - onCancel(); + onCancel!(); }; if (!status) { @@ -23,7 +23,7 @@ const ReplyIndicator: React.FC = ({ status, hideActions, onCanc } let actions = {}; - if (!hideActions) { + if (!hideActions && onCancel) { actions = { onActionClick: handleClick, actionIcon: require('@tabler/icons/icons/x.svg'), diff --git a/app/soapbox/features/crypto_donate/components/crypto_address.tsx b/app/soapbox/features/crypto_donate/components/crypto_address.tsx index 3fb28f6e4f..afffd085a3 100644 --- a/app/soapbox/features/crypto_donate/components/crypto_address.tsx +++ b/app/soapbox/features/crypto_donate/components/crypto_address.tsx @@ -10,7 +10,7 @@ import { getTitle } from '../utils/coin_db'; import CryptoIcon from './crypto_icon'; -interface ICryptoAddress { +export interface ICryptoAddress { address: string, ticker: string, note?: string, diff --git a/app/soapbox/features/scheduled_statuses/components/scheduled_status.tsx b/app/soapbox/features/scheduled_statuses/components/scheduled_status.tsx index 451529a328..15a8e1ed9e 100644 --- a/app/soapbox/features/scheduled_statuses/components/scheduled_status.tsx +++ b/app/soapbox/features/scheduled_statuses/components/scheduled_status.tsx @@ -13,7 +13,7 @@ import { buildStatus } from '../builder'; import ScheduledStatusActionBar from './scheduled_status_action_bar'; -import type { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities'; +import type { Account as AccountEntity, Poll as PollEntity, Status as StatusEntity } from 'soapbox/types/entities'; interface IScheduledStatus { statusId: string, @@ -55,7 +55,7 @@ const ScheduledStatus: React.FC = ({ statusId, ...other }) => /> )} - {status.poll && } + {status.poll && } diff --git a/app/soapbox/features/ui/components/boost_modal.js b/app/soapbox/features/ui/components/boost_modal.js deleted file mode 100644 index faf648b1254ee7f7b5202a5c175c43a8252d0886..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2272 zcmds2&2HN`5Wf28iw6Hh20#?&`>HGzIGm{asMJ`+~H~#-9x~i(i z@m-0hb^>lG2l3L|Juy4#HU=*>`BJE!_?hYxW+?{H7(fdJ?xn)_Xf3}*y8x;FMd7ZL zD;MyWHWhaci(U-fG>xSs(A3m7=?+`nI5a0f6E2s9t_VJqD2anU2ux%+HrBWfRFg#jy}$4H*(b7VqHF7sX_|wv^nv(NA9RJHoCSr4Z(QD8#!qD z&?zYEpz4bS`APMXb_O805?J0C+?D!v1ue*81@%EfPWj!c&bBY`v0$+PSa4|kJT#WBF6D7A6{?McwDh^a=RE32f zu&td@Y(6(Bz;iVALJqzVQP9}cM0tRu28A|7D(x2kYox)#Ckdd{wy)cqRnA67^812}M1lo-RKmrv%9Z~8nPsi!`Dn+^#i zle_r#^a?)1$-Pz~ha^b4(Z@R>bfes5DaD=lgcDbCPv>;kI7i)+=Q+HBmoMQ3-3e#P zzwr^ie+Nt}bes~55#5ZO3YcDHE-GRo+8>yzdEE=?}Y!(BUz?B=ibk(iA6 z%?HiR(ZZT&M7?5bE--IjccX-2rtqc>- HsGI!{5&iL8 diff --git a/app/soapbox/features/ui/components/boost_modal.tsx b/app/soapbox/features/ui/components/boost_modal.tsx new file mode 100644 index 0000000000..1dcaaf63d2 --- /dev/null +++ b/app/soapbox/features/ui/components/boost_modal.tsx @@ -0,0 +1,48 @@ +import React from 'react'; +import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; + +import Icon from 'soapbox/components/icon'; +import { Modal, Stack, Text } from 'soapbox/components/ui'; +import ReplyIndicator from 'soapbox/features/compose/components/reply_indicator'; + +import type { Status as StatusEntity } from 'soapbox/types/entities'; + +const messages = defineMessages({ + cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Un-repost' }, + reblog: { id: 'status.reblog', defaultMessage: 'Repost' }, +}); + +interface IBoostModal { + status: StatusEntity, + onReblog: (status: StatusEntity) => void, + onClose: () => void, +} + +const BoostModal: React.FC = ({ status, onReblog, onClose }) => { + const intl = useIntl(); + + const handleReblog = () => { + onReblog(status); + onClose(); + }; + + const buttonText = status.reblogged ? messages.cancel_reblog : messages.reblog; + + return ( + + + + + + Shift + }} /> + + + + ); +}; + +export default BoostModal; diff --git a/app/soapbox/features/ui/components/confirmation_modal.js b/app/soapbox/features/ui/components/confirmation_modal.js deleted file mode 100644 index e205f6ce180d9f9a0be15fafb05413c0cb873ec8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2293 zcmbtVOK+P%5Wf3YOfSKaY_M9XhXkxvRH<@ES|zzhYZ&ZpFiY8Wl?d_QJNw{ehlS<6#T42`Sezzgsc)r@Jf1KD}CTyFSx}#AWM|Huk`=^ss>*C!bIH` zDqq2ksE$l2Oz%)iwnu1&R%=cmGHq#VxDzSMJCGEt+=X%E<@ZXQ$`!;1OkT)zLX{y?rwV0|k&(`5fv+a*6f<_p6@2N#UnDt`5@JzgT&KZB zVdKMBg+(gC$l(7ZzPODL>cs*;DnciqrL$5-bPn`6AWM0%zv@-?3z6c=T=GN|^EXGU z-ub1^~tH=g~W;kN6?-madjUOwE{O(Y+D+HwjKtL=@n!wm!=Gj1|3+D<{0NZ zc_HZX5~8gupgM5r>$*zciMaIQANM!64|m?>wJGBmV)a{^y8(A6#((m6JQEMGk?D+{ ziX;`(;9_6tKNi;zvX9(m@?M5KgJo-Y*-=a*aK(s8P8$6P=sVI;qI#rB!DS6yA<$Q> z+N1K_2{gTQ6-^yhR1P~#Z8C1CR^Y~D1$3k5UozqqgJ;`Vq2cSY) z9R(~+l>tJt4BP{N;ws0ecEL2=xr@cDkFSYdB2jIG9yHlJ`ib^TR6F~5$Tu$8F2|H$ zZF(0M@WG`qZ}W7(BSv1Ti&A-goTd+~&v3H0c^Y}cOrDQ=Q~QZA^1y9Rx8)3W7*9FkQM`}yYrT4+a({CV3z$o)6ysse!Z{Q+xqin z1GLp%uKJ@-n~k@vU8^-=P;T|cu%9sHe}+Uywf^Y!UI0dAI!6!nT^oI$pWCvISg7~< zH{Xz6M-dKQgy(m38@oQ~Vs@d^4~?{$)Ny}~hPYL(Hv-7n4)eYN=OC^h9SGAYCO8i@ e4BpKn4Cb>B1CoExaQ4|H8U|)ut($hGG>gB$70xXH diff --git a/app/soapbox/features/ui/components/confirmation_modal.tsx b/app/soapbox/features/ui/components/confirmation_modal.tsx new file mode 100644 index 0000000000..8b4d790e66 --- /dev/null +++ b/app/soapbox/features/ui/components/confirmation_modal.tsx @@ -0,0 +1,82 @@ +import React, { useState } from 'react'; +import { FormattedMessage } from 'react-intl'; + +import { Modal } from 'soapbox/components/ui'; +import { SimpleForm, FieldsGroup, Checkbox } from 'soapbox/features/forms'; + +interface IConfirmationModal { + heading: React.ReactNode, + message: React.ReactNode, + confirm: React.ReactNode, + onClose: (type: string) => void, + onConfirm: () => void, + secondary: React.ReactNode, + onSecondary?: () => void, + onCancel: () => void, + checkbox?: JSX.Element, +} + +const ConfirmationModal: React.FC = ({ + heading, + message, + confirm, + onClose, + onConfirm, + secondary, + onSecondary, + onCancel, + checkbox, +}) => { + const [checked, setChecked] = useState(false); + + const handleClick = () => { + onClose('CONFIRM'); + onConfirm(); + }; + + const handleSecondary = () => { + onClose('CONFIRM'); + onSecondary!(); + }; + + const handleCancel = () => { + onClose('CONFIRM'); + if (onCancel) onCancel(); + }; + + const handleCheckboxChange: React.ChangeEventHandler = e => { + setChecked(e.target.checked); + }; + + return ( + } + cancelAction={handleCancel} + secondaryText={secondary} + secondaryAction={onSecondary && handleSecondary} + > +

{message}

+ +
+ {checkbox &&
+ + + + + +
} +
+
+ ); +}; + +export default ConfirmationModal; diff --git a/app/soapbox/features/ui/components/crypto_donate_modal.js b/app/soapbox/features/ui/components/crypto_donate_modal.js deleted file mode 100644 index 73d8b25db46103cf9a0a145afa2f413413435c23..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 543 zcma)3O;5ux488YP_|{FL>78vzXuE=@iF*|q7b4oEI3DUW?Z4wBtvJAeoD%!_eK>X) zJuw`~k1v-I19apEC`Wl$91G>9uo-hg-SXV0c$e1FJ0NS@quJACWdCRkVOY3=*W;_7 z>JBxZrCzrQ)EMtHW8He8cj!3OW@c$-gw8xs2dCuIV5iSLL)&ZN&uWLn^W=^00VhUh z0wk~MD02IS9SbbEi(r1NH_>BJ+=_4N3%K?G diff --git a/app/soapbox/features/ui/components/crypto_donate_modal.tsx b/app/soapbox/features/ui/components/crypto_donate_modal.tsx new file mode 100644 index 0000000000..805012d3a4 --- /dev/null +++ b/app/soapbox/features/ui/components/crypto_donate_modal.tsx @@ -0,0 +1,16 @@ +import React from 'react'; + +import DetailedCryptoAddress from 'soapbox/features/crypto_donate/components/detailed_crypto_address'; + +import type { ICryptoAddress } from '../../crypto_donate/components/crypto_address'; + +const CryptoDonateModal: React.FC = (props) => { + return ( +
+ +
+ ); + +}; + +export default CryptoDonateModal; diff --git a/app/soapbox/features/ui/components/list_panel.js b/app/soapbox/features/ui/components/list_panel.js deleted file mode 100644 index 4ca1a78ff2932ac8ab179dff1c65b569ba2b4f44..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1486 zcmZ`(O>f&U488kTu)qLIKx|)jYU`lDwnKrgE7}4(3`48f@*-50JW1|Sxc={>5ZtyvA{vtk$#NczwS>Z;z@#n>KS=X&&JIRl6 zf?pygbK-H2V3*j|@J||ZDX!k+S;wPKQcO-u0UZ=tDUS8^>k1RY%l5E#yJpWUtelAQQ*$xWpWK9b&^3x=wBCpyICBUkU5%3~e=QcKVQE*MwF! zlis@EUt;xR-IM1`(q;m!J^}t&2fw)cW=f9Ch7>uxt&RM!4oii63*nGr0Evf$^ydb` z$y>V!KvY0Z!VL}20EWBPsKM(DJ^BcL)|aW%J~5$bB_y_w2*+!WcXHxSG_@!wLf8g& z)L*lq04JQ}F-@f|m<)4fhLhbJBc-WhPn>+DXHk#ek#WtMJ5T9edwE&N2Vx$acoL!h z)8odFz@BafBz_1wFL}jU>EL1+e{?ZQhaBahQ6ZVN;Mv|V#U=2AWO-v9$N#b_;FW0i}I^( z6^>*~H3+4HDJ9A<2e%hC^<`N>Ludl;UklU9U z7aoDf(q=8GR?4A}ps@L#1T28_Qao?RGd}GNWLwXA_;jI;6emXfDM(>9qWie!@Wfy8 z;5+C{lrilgjP;t;JdX=4+gc?OUkTXH`J5!qFop9n_$rEVrbgha#p%3z46B=cI0k*} zx94Gt{|)}|5SAE3nTJ(OS{Xwn4!ry>O1DRDE5LD8`txk0vGjq`e(Fy)H)tAKAN>VM CtL_*8 diff --git a/app/soapbox/features/ui/components/list_panel.tsx b/app/soapbox/features/ui/components/list_panel.tsx new file mode 100644 index 0000000000..14d6fc82cc --- /dev/null +++ b/app/soapbox/features/ui/components/list_panel.tsx @@ -0,0 +1,45 @@ +import React, { useEffect } from 'react'; +import { NavLink } from 'react-router-dom'; +import { createSelector } from 'reselect'; + +import { fetchLists } from 'soapbox/actions/lists'; +import Icon from 'soapbox/components/icon'; +import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; + +import type { List as ImmutableList } from 'immutable'; +import type { RootState } from 'soapbox/store'; +import type { List as ListEntity } from 'soapbox/types/entities'; + +const getOrderedLists = createSelector([(state: RootState) => state.lists], lists => { + if (!lists) { + return lists; + } + + return lists.toList().filter(item => !!item).sort((a, b) => (a as ListEntity).title.localeCompare((b as ListEntity).title)).take(4) as ImmutableList;; +}); + +const ListPanel = () => { + const dispatch = useAppDispatch(); + + const lists = useAppSelector((state) => getOrderedLists(state)); + + useEffect(() => { + dispatch(fetchLists()); + }, []); + + if (!lists || lists.isEmpty()) { + return null; + } + + return ( +
+
+ + {lists.map(list => ( + {list.title} + ))} +
+ ); +}; + +export default ListPanel; diff --git a/app/soapbox/features/ui/components/mute_modal.js b/app/soapbox/features/ui/components/mute_modal.js deleted file mode 100644 index 0714b5cfb157117c59c7fc62dfa3cf3e57da6760..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3106 zcma)8O>f&c5WV|X%uP1nO2A@IiIpbEV$mM5DB9c>MZrj8n;VJriqtlRp#Q$Z4@sn? zv@r}wB4>s(k8d8y>x*nOd}`$7@y7)f92;3fa-r{c+6*Mu8}4jABP+C@Z_N8N)d3g( zV4*(>UG3pd+0;yHEFVxQc0%YwuXmh`Lf1kHLB2Dq2FvzkGJBM#Q-x6+ZHLHYNU(#t z)p%DFvK3P}CE4XkzGRdzmqO9g&Ig5cP*hUkgDhD!W-)iG&1~f4*8jju{7Y(nnZnLtw-YIY$njgQi7pn@Ef`Goui zx(z^sx^0Ag1>ovS`&4tSxj0=pyR<>G`zjUqJq_pgU?wp$l(fE~fWb8xq*BkmzCH}$Hh3VovRayFx)k3AXm*U8qdh0XWL$u1y0|GFF z*#^8BoKh-xoA5H(&E0p`7M*^-u}@mguxGmxcB0jGxA1a|j;OO1;}w>L0RcQ>_+p#6 z#3O4f4Y$6twlkXS4R2>zSiUVEeh?9ttb{zN9Mf2 za%KB|>1C8JG+HgrP#@sTL|Nf|#fxX^Y9fYjX#joZDm6f>bflhRWIW@0AQ&9mAsCB* zv>fe&<(Vk3dgJ=m&#^Tk_0QZ_K-^AAG{iY<#-?zR*A22XYfF;dJix|+I4a=Qb}GQZ z(%F9ylw4Ps8>Jk6hxyqR%#nnac|utjZE;$k8sSLK$Vw8`B(n8Q=#RiWG0g}LF!hCLVZ&Tg)!kKMn?Cd~cL9*42HVcWX3 zIh68lfzE4)_=OT!Lm`3eCRoMh_}2K}>@l1c)@d33-j6RASSvR|XTtPg4`QG*ryz3t z-cK_`Ad_e~Ktn&J%&VlS-Q6gr0v$Z-{XEE= zQ3s_PDNZ-HotJ=+Tm2#P(=p3{wrS)Um6^HH!=Z{jVHFyYnY+yZtN2NL)L1KO8M?P% zlMIOd79nan&!P&No$`cG7fBq_TFgPV%ro8R8F8j-*tbZ`mh3QBwfHLF?vtitpjFts zH`ELYv@0*`b}8H2=gb(OIAigQW!^=(OmsKC=11*HJ$fR7*?wKo&7}`F3Yd3Cx`*O? gc9!=cbNdihbI4} { + const dispatch = useAppDispatch(); + + const account = useAppSelector((state) => getAccount(state, state.mutes.new.accountId!)); + const notifications = useAppSelector((state) => state.mutes.new.notifications); + + if (!account) return null; + + const handleClick = () => { + dispatch(closeModal()); + dispatch(muteAccount(account.id, notifications)); + }; + + const handleCancel = () => { + dispatch(closeModal()); + }; + + const toggleNotifications = () => { + dispatch(toggleHideNotifications()); + }; + + return ( + + } + onClose={handleCancel} + confirmationAction={handleClick} + confirmationText={} + cancelText={} + cancelAction={handleCancel} + > + + + @{account.acct} }} + /> + + + + + + ); +}; + +export default MuteModal; diff --git a/app/soapbox/features/ui/components/pending_status.tsx b/app/soapbox/features/ui/components/pending_status.tsx index 03853008cd..9e7bfaef1f 100644 --- a/app/soapbox/features/ui/components/pending_status.tsx +++ b/app/soapbox/features/ui/components/pending_status.tsx @@ -14,7 +14,7 @@ import { buildStatus } from '../util/pending_status_builder'; import PollPreview from './poll_preview'; -import type { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities'; +import type { Account as AccountEntity, Poll as PollEntity, Status as StatusEntity } from 'soapbox/types/entities'; const shouldHaveCard = (pendingStatus: StatusEntity) => { return Boolean(pendingStatus.content.match(/https?:\/\/\S*/)); @@ -81,7 +81,7 @@ const PendingStatus: React.FC = ({ idempotencyKey, className, mu - {status.poll && } + {status.poll && } {status.quote && } diff --git a/app/soapbox/features/ui/components/poll_preview.js b/app/soapbox/features/ui/components/poll_preview.js deleted file mode 100644 index 40766abe420802a2d79e9b417668e47c518bce35..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1229 zcma)5%WmT^47}$n*pqA^k9!(t54~)Gb~otu9w;``2$dy6lG6mP|9vSbegVN^bBRn+ z!{Klw%1Rptx#ZUV;w4%*8eIYl0p$biaVBEX8}i)U^2VQs)N@(ZjvplMjIQ3VRgV+u z7NScpD#|;bzjwDb_@t?qLN)0#zE3rayelG*8D7E!1s-`VZ0K4ItOb zI%onAw2*;23A^-->|^K<3+zdMy`iNEEYS*Q|+5+U+gwGyH&Z*ml+oi%*#Ey5Bp}i_M9#MTvP>>KY!#{MvK`NuWYi zwd;F$)x2@Czab{PUnM4A#I5FN9|8h5(n;~7oM=uwUyUD z=$@5A^Yi`nC2Jbk?@z8Imqn?d4FEm2RoGd#!_7*Hc&6o({Ra0X|K+$awKziZ;MMQ0 z^cGUJl+l&}xsUhOD#UptRIm)|xRDiVIeY+&Hr&}D^$#bxy^%SH6tZo65_jH^&!@vK PH>&}Dvmz!_A==qrDi?i> diff --git a/app/soapbox/features/ui/components/poll_preview.tsx b/app/soapbox/features/ui/components/poll_preview.tsx new file mode 100644 index 0000000000..3d3b484087 --- /dev/null +++ b/app/soapbox/features/ui/components/poll_preview.tsx @@ -0,0 +1,44 @@ +import classNames from 'classnames'; +import React from 'react'; + +import { Poll as PollEntity, PollOption as PollOptionEntity } from 'soapbox/types/entities'; + +interface IPollPreview { + poll: PollEntity, +} + +const PollPreview: React.FC = ({ poll }) => { + const renderOption = (option: PollOptionEntity, index: number) => { + const showResults = poll.voted || poll.expired; + + return ( +
  • + +
  • + ); + }; + + if (!poll) { + return null; + } + + return ( +
    +
      + {poll.options.map((option, i) => renderOption(option, i))} +
    +
    + ); +}; + +export default PollPreview; diff --git a/app/soapbox/reducers/mutes.js b/app/soapbox/reducers/mutes.ts similarity index 50% rename from app/soapbox/reducers/mutes.js rename to app/soapbox/reducers/mutes.ts index 8cc6fc4a84e427e600aa86bc3ae6142b99239c89..e232d4039c3506dfc737d14786566aaa6c40fb43 100644 GIT binary patch delta 394 zcmZvYJxT*X6vx?s2y0~_HWm*HHv!23#t%rjMJzUHEhaN>WngC}%)B9n5ON0D-r56r z1W)4`ESyb7qhkBx|NbBE}$!Z`+gXqF}Js|HzJ(aX?p-ZJ*SRv$xYy7WZFxnC1keQcRl9`wj zT#{Ils$h$vNTZrdK_M@-+zL}vK_Rm^xHKs@v!o<5FWpKZEitD!RR^eCK_M|YIlnZo z#7ZHrG$#inG?|}KoI^pOR#S(oR&(-PMl~UzJ;>JTC?rmP#dt(WJr>AHF3HT#(}Nl^ Qxt&R2au~DV Date: Sun, 12 Jun 2022 16:30:48 +0200 Subject: [PATCH 2/4] Fix mutes test, prefer TypeScript for tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../{preload-test.js => preload.test.ts} | Bin .../{statuses-test.js => statuses.test.ts} | Bin ...est.js => password_reset_confirm.test.tsx} | Bin .../{emoji-test.js => emoji.test.ts} | Bin ...moji_index-test.js => emoji_index.test.ts} | Bin .../{account-test.js => account.test.ts} | Bin ...{attachment-test.js => attachment.test.ts} | Bin .../__tests__/{card-test.js => card.test.ts} | Bin .../{mention-test.js => mention.test.ts} | Bin ...ification-test.js => notification.test.ts} | Bin .../__tests__/{poll-test.js => poll.test.ts} | Bin .../{status-test.js => status.test.ts} | Bin app/soapbox/normalizers/poll.ts | 12 +++++++++++- ..._config-test.js => soapbox_config-test.ts} | Bin .../{accounts-test.js => accounts.test.ts} | Bin 1009 -> 1016 bytes ...ters-test.js => accounts_counters.test.ts} | Bin 1465 -> 1472 bytes .../{admin-test.js => admin.test.ts} | Bin 325 -> 332 bytes .../{alerts-test.js => alerts.test.ts} | Bin .../__tests__/{auth-test.js => auth.test.ts} | Bin ...rsations-test.js => conversations.test.ts} | Bin ...m_emojis-test.js => custom_emojis.test.ts} | Bin .../{filters-test.js => filters.test.ts} | Bin 242 -> 249 bytes ...up_editor-test.js => group_editor.test.ts} | Bin ...roup_lists-test.js => group_lists.test.ts} | Bin ...ps-test.js => group_relationships.test.ts} | Bin .../{groups-test.js => groups.test.ts} | Bin .../{index-test.js => index.test.ts} | Bin .../{instance-test.js => instance.test.ts} | Bin 3852 -> 3866 bytes .../{lists-test.js => lists.test.ts} | Bin 235 -> 242 bytes .../__tests__/{me-test.js => me.test.ts} | Bin 169 -> 176 bytes .../__tests__/{meta-test.js => meta.test.ts} | Bin .../{mutes-test.js => mutes.test.ts} | Bin 1325 -> 1302 bytes .../{patron-test.js => patron.test.ts} | Bin 934 -> 941 bytes .../{polls-test.js => polls.test.ts} | Bin 902 -> 909 bytes ...ons-test.js => push_notifications.test.ts} | Bin 535 -> 531 bytes .../{reports-test.js => reports.test.ts} | Bin 379 -> 386 bytes .../{settings-test.js => settings.test.ts} | Bin .../{sidebar-test.js => sidebar.test.ts} | Bin 197 -> 204 bytes .../{soapbox-test.js => soapbox.test.ts} | Bin .../{statuses-test.js => statuses.test.ts} | Bin .../{trends-test.js => trends.test.ts} | Bin ...{user_lists-test.js => user_lists.test.ts} | Bin ...ification-test.js => verification.test.ts} | Bin .../{accounts-test.js => accounts.test.ts} | Bin .../{base64-test.js => base64.test.ts} | Bin .../{colors-test.js => colors.test.ts} | Bin .../{features-test.js => features.test.ts} | Bin .../__tests__/{html-test.js => html.test.ts} | Bin .../{phone-test.js => phone.test.ts} | Bin .../{status-test.js => status.test.ts} | Bin .../{tailwind-test.js => tailwind.test.ts} | Bin 51 files changed, 11 insertions(+), 1 deletion(-) rename app/soapbox/actions/__tests__/{preload-test.js => preload.test.ts} (100%) rename app/soapbox/actions/__tests__/{statuses-test.js => statuses.test.ts} (100%) rename app/soapbox/features/auth_login/components/__tests__/{password_reset_confirm-test.js => password_reset_confirm.test.tsx} (100%) rename app/soapbox/features/emoji/__tests__/{emoji-test.js => emoji.test.ts} (100%) rename app/soapbox/features/emoji/__tests__/{emoji_index-test.js => emoji_index.test.ts} (100%) rename app/soapbox/normalizers/__tests__/{account-test.js => account.test.ts} (100%) rename app/soapbox/normalizers/__tests__/{attachment-test.js => attachment.test.ts} (100%) rename app/soapbox/normalizers/__tests__/{card-test.js => card.test.ts} (100%) rename app/soapbox/normalizers/__tests__/{mention-test.js => mention.test.ts} (100%) rename app/soapbox/normalizers/__tests__/{notification-test.js => notification.test.ts} (100%) rename app/soapbox/normalizers/__tests__/{poll-test.js => poll.test.ts} (100%) rename app/soapbox/normalizers/__tests__/{status-test.js => status.test.ts} (100%) rename app/soapbox/normalizers/soapbox/__tests__/{soapbox_config-test.js => soapbox_config-test.ts} (100%) rename app/soapbox/reducers/__tests__/{accounts-test.js => accounts.test.ts} (93%) rename app/soapbox/reducers/__tests__/{accounts_counters-test.js => accounts_counters.test.ts} (95%) rename app/soapbox/reducers/__tests__/{admin-test.js => admin.test.ts} (84%) rename app/soapbox/reducers/__tests__/{alerts-test.js => alerts.test.ts} (100%) rename app/soapbox/reducers/__tests__/{auth-test.js => auth.test.ts} (100%) rename app/soapbox/reducers/__tests__/{conversations-test.js => conversations.test.ts} (100%) rename app/soapbox/reducers/__tests__/{custom_emojis-test.js => custom_emojis.test.ts} (100%) rename app/soapbox/reducers/__tests__/{filters-test.js => filters.test.ts} (72%) rename app/soapbox/reducers/__tests__/{group_editor-test.js => group_editor.test.ts} (100%) rename app/soapbox/reducers/__tests__/{group_lists-test.js => group_lists.test.ts} (100%) rename app/soapbox/reducers/__tests__/{group_relationships-test.js => group_relationships.test.ts} (100%) rename app/soapbox/reducers/__tests__/{groups-test.js => groups.test.ts} (100%) rename app/soapbox/reducers/__tests__/{index-test.js => index.test.ts} (100%) rename app/soapbox/reducers/__tests__/{instance-test.js => instance.test.ts} (97%) rename app/soapbox/reducers/__tests__/{lists-test.js => lists.test.ts} (72%) rename app/soapbox/reducers/__tests__/{me-test.js => me.test.ts} (67%) rename app/soapbox/reducers/__tests__/{meta-test.js => meta.test.ts} (100%) rename app/soapbox/reducers/__tests__/{mutes-test.js => mutes.test.ts} (54%) rename app/soapbox/reducers/__tests__/{patron-test.js => patron.test.ts} (94%) rename app/soapbox/reducers/__tests__/{polls-test.js => polls.test.ts} (92%) rename app/soapbox/reducers/__tests__/{push_notifications-test.js => push_notifications.test.ts} (93%) rename app/soapbox/reducers/__tests__/{reports-test.js => reports.test.ts} (84%) rename app/soapbox/reducers/__tests__/{settings-test.js => settings.test.ts} (100%) rename app/soapbox/reducers/__tests__/{sidebar-test.js => sidebar.test.ts} (63%) rename app/soapbox/reducers/__tests__/{soapbox-test.js => soapbox.test.ts} (100%) rename app/soapbox/reducers/__tests__/{statuses-test.js => statuses.test.ts} (100%) rename app/soapbox/reducers/__tests__/{trends-test.js => trends.test.ts} (100%) rename app/soapbox/reducers/__tests__/{user_lists-test.js => user_lists.test.ts} (100%) rename app/soapbox/reducers/__tests__/{verification-test.js => verification.test.ts} (100%) rename app/soapbox/utils/__tests__/{accounts-test.js => accounts.test.ts} (100%) rename app/soapbox/utils/__tests__/{base64-test.js => base64.test.ts} (100%) rename app/soapbox/utils/__tests__/{colors-test.js => colors.test.ts} (100%) rename app/soapbox/utils/__tests__/{features-test.js => features.test.ts} (100%) rename app/soapbox/utils/__tests__/{html-test.js => html.test.ts} (100%) rename app/soapbox/utils/__tests__/{phone-test.js => phone.test.ts} (100%) rename app/soapbox/utils/__tests__/{status-test.js => status.test.ts} (100%) rename app/soapbox/utils/__tests__/{tailwind-test.js => tailwind.test.ts} (100%) diff --git a/app/soapbox/actions/__tests__/preload-test.js b/app/soapbox/actions/__tests__/preload.test.ts similarity index 100% rename from app/soapbox/actions/__tests__/preload-test.js rename to app/soapbox/actions/__tests__/preload.test.ts diff --git a/app/soapbox/actions/__tests__/statuses-test.js b/app/soapbox/actions/__tests__/statuses.test.ts similarity index 100% rename from app/soapbox/actions/__tests__/statuses-test.js rename to app/soapbox/actions/__tests__/statuses.test.ts diff --git a/app/soapbox/features/auth_login/components/__tests__/password_reset_confirm-test.js b/app/soapbox/features/auth_login/components/__tests__/password_reset_confirm.test.tsx similarity index 100% rename from app/soapbox/features/auth_login/components/__tests__/password_reset_confirm-test.js rename to app/soapbox/features/auth_login/components/__tests__/password_reset_confirm.test.tsx diff --git a/app/soapbox/features/emoji/__tests__/emoji-test.js b/app/soapbox/features/emoji/__tests__/emoji.test.ts similarity index 100% rename from app/soapbox/features/emoji/__tests__/emoji-test.js rename to app/soapbox/features/emoji/__tests__/emoji.test.ts diff --git a/app/soapbox/features/emoji/__tests__/emoji_index-test.js b/app/soapbox/features/emoji/__tests__/emoji_index.test.ts similarity index 100% rename from app/soapbox/features/emoji/__tests__/emoji_index-test.js rename to app/soapbox/features/emoji/__tests__/emoji_index.test.ts diff --git a/app/soapbox/normalizers/__tests__/account-test.js b/app/soapbox/normalizers/__tests__/account.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/account-test.js rename to app/soapbox/normalizers/__tests__/account.test.ts diff --git a/app/soapbox/normalizers/__tests__/attachment-test.js b/app/soapbox/normalizers/__tests__/attachment.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/attachment-test.js rename to app/soapbox/normalizers/__tests__/attachment.test.ts diff --git a/app/soapbox/normalizers/__tests__/card-test.js b/app/soapbox/normalizers/__tests__/card.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/card-test.js rename to app/soapbox/normalizers/__tests__/card.test.ts diff --git a/app/soapbox/normalizers/__tests__/mention-test.js b/app/soapbox/normalizers/__tests__/mention.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/mention-test.js rename to app/soapbox/normalizers/__tests__/mention.test.ts diff --git a/app/soapbox/normalizers/__tests__/notification-test.js b/app/soapbox/normalizers/__tests__/notification.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/notification-test.js rename to app/soapbox/normalizers/__tests__/notification.test.ts diff --git a/app/soapbox/normalizers/__tests__/poll-test.js b/app/soapbox/normalizers/__tests__/poll.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/poll-test.js rename to app/soapbox/normalizers/__tests__/poll.test.ts diff --git a/app/soapbox/normalizers/__tests__/status-test.js b/app/soapbox/normalizers/__tests__/status.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/status-test.js rename to app/soapbox/normalizers/__tests__/status.test.ts diff --git a/app/soapbox/normalizers/poll.ts b/app/soapbox/normalizers/poll.ts index d2b1bf4924..7b98d1354f 100644 --- a/app/soapbox/normalizers/poll.ts +++ b/app/soapbox/normalizers/poll.ts @@ -47,8 +47,18 @@ const normalizeEmojis = (entity: ImmutableMap) => { }); }; -const normalizePollOption = (option: ImmutableMap, emojis: ImmutableList> = ImmutableList()) => { +const normalizePollOption = (option: ImmutableMap | string, emojis: ImmutableList> = ImmutableList()) => { const emojiMap = makeEmojiMap(emojis); + + if (typeof option === 'string') { + const titleEmojified = emojify(escapeTextContentForBrowser(option), emojiMap); + + return PollOptionRecord({ + title: option, + title_emojified: titleEmojified, + }); + } + const titleEmojified = emojify(escapeTextContentForBrowser(option.get('title')), emojiMap); return PollOptionRecord( diff --git a/app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.js b/app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.ts similarity index 100% rename from app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.js rename to app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.ts diff --git a/app/soapbox/reducers/__tests__/accounts-test.js b/app/soapbox/reducers/__tests__/accounts.test.ts similarity index 93% rename from app/soapbox/reducers/__tests__/accounts-test.js rename to app/soapbox/reducers/__tests__/accounts.test.ts index 4b7915d3246f2eb3d5269b178218b576776db985..647bb676a22e936e5168a53c5933b1f49d065cb9 100644 GIT binary patch delta 20 bcmey!{)2sk5+l1pVzEMEUgc&b#`8=7OpXTC delta 12 Tcmeyt{*iry660n~#`8=7A>0Ic diff --git a/app/soapbox/reducers/__tests__/accounts_counters-test.js b/app/soapbox/reducers/__tests__/accounts_counters.test.ts similarity index 95% rename from app/soapbox/reducers/__tests__/accounts_counters-test.js rename to app/soapbox/reducers/__tests__/accounts_counters.test.ts index ca1a279e0c960a93923d2da0a5ee481f421b99b0..114f28b54e95f6f3591a7365ecc07d38a9c6a905 100644 GIT binary patch delta 20 bcmdnVeSmwzTqbsf#A1cSyvogUnPiv&Oq&L? delta 12 TcmX@Wy_0*xT&B%Sm}Hm%AxQ*R diff --git a/app/soapbox/reducers/__tests__/admin-test.js b/app/soapbox/reducers/__tests__/admin.test.ts similarity index 84% rename from app/soapbox/reducers/__tests__/admin-test.js rename to app/soapbox/reducers/__tests__/admin.test.ts index 43018c88005ec55594082081e2055aab1bef28a5..a83e110226dd77fbac486b8e7aaec0d94168d727 100644 GIT binary patch delta 17 YcmX@gbcSidWp;(cVui%K%88eY06r53G5`Po delta 9 QcmX@Zbd+hr<%ze702ZkP)&Kwi diff --git a/app/soapbox/reducers/__tests__/alerts-test.js b/app/soapbox/reducers/__tests__/alerts.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/alerts-test.js rename to app/soapbox/reducers/__tests__/alerts.test.ts diff --git a/app/soapbox/reducers/__tests__/auth-test.js b/app/soapbox/reducers/__tests__/auth.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/auth-test.js rename to app/soapbox/reducers/__tests__/auth.test.ts diff --git a/app/soapbox/reducers/__tests__/conversations-test.js b/app/soapbox/reducers/__tests__/conversations.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/conversations-test.js rename to app/soapbox/reducers/__tests__/conversations.test.ts diff --git a/app/soapbox/reducers/__tests__/custom_emojis-test.js b/app/soapbox/reducers/__tests__/custom_emojis.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/custom_emojis-test.js rename to app/soapbox/reducers/__tests__/custom_emojis.test.ts diff --git a/app/soapbox/reducers/__tests__/filters-test.js b/app/soapbox/reducers/__tests__/filters.test.ts similarity index 72% rename from app/soapbox/reducers/__tests__/filters-test.js rename to app/soapbox/reducers/__tests__/filters.test.ts index 90bfc1323497d3bfa9a86724fc0c11941ddb94b2..5faa0f948d0ba8b14e0c6704c26f7faf36835e6c 100644 GIT binary patch delta 17 Ycmeyw_>*zMX?BIgVui%K%894d0YcgbF8}}l delta 9 Qcmey#_=$1C>4}%r0T}QE(*OVf diff --git a/app/soapbox/reducers/__tests__/group_editor-test.js b/app/soapbox/reducers/__tests__/group_editor.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/group_editor-test.js rename to app/soapbox/reducers/__tests__/group_editor.test.ts diff --git a/app/soapbox/reducers/__tests__/group_lists-test.js b/app/soapbox/reducers/__tests__/group_lists.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/group_lists-test.js rename to app/soapbox/reducers/__tests__/group_lists.test.ts diff --git a/app/soapbox/reducers/__tests__/group_relationships-test.js b/app/soapbox/reducers/__tests__/group_relationships.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/group_relationships-test.js rename to app/soapbox/reducers/__tests__/group_relationships.test.ts diff --git a/app/soapbox/reducers/__tests__/groups-test.js b/app/soapbox/reducers/__tests__/groups.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/groups-test.js rename to app/soapbox/reducers/__tests__/groups.test.ts diff --git a/app/soapbox/reducers/__tests__/index-test.js b/app/soapbox/reducers/__tests__/index.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/index-test.js rename to app/soapbox/reducers/__tests__/index.test.ts diff --git a/app/soapbox/reducers/__tests__/instance-test.js b/app/soapbox/reducers/__tests__/instance.test.ts similarity index 97% rename from app/soapbox/reducers/__tests__/instance-test.js rename to app/soapbox/reducers/__tests__/instance.test.ts index 33a5fab55ed63f4678ed4be284c8451e940f92fd..8357d6851f3748090d93e0ed053ce18c2f5c3e6e 100644 GIT binary patch delta 40 qcmeB?nHH}LtGq)hWs6?S!At*IDzbHi^u~@+~H@CDTF)1e%BD7J4n^8`$B;PAoLsJt- zyB3xv=4e!NDS$ymSYx&F?E>qAqsW5 zH8i10H8my&vS>}-$s{dQt&o{wrJ$aeoSa{pS7NBHP&@e^lNOP-r!yNN*{(7%TypY# oW;K}2NRD{NA~m^(nGekcxrD5F&!R30bFwwim$jPKTwEXm0CH+uEC2ui delta 303 zcmbQnwU$dJGq)hWs6?S!!8fr$A+cD&GdH)iBrz!`70BPH#LXzCsaKNkT3DKxqk$|n z`9HHb3s8y1WL;*x$<>THoSHgZ3P4b+Ie8sp2s2O$LkR~=$z*>Pt;su>q`A}+laupH z^GXcWCqHGzKnf?6ys(^#vUdB8jJ&w diff --git a/app/soapbox/reducers/__tests__/polls-test.js b/app/soapbox/reducers/__tests__/polls.test.ts similarity index 92% rename from app/soapbox/reducers/__tests__/polls-test.js rename to app/soapbox/reducers/__tests__/polls.test.ts index b19ad858c5d2c98f745fc6c024aa6b53ce8fb2fe..b9ceb07f773908a18fb3d1c28ead0d03a252a847 100644 GIT binary patch delta 18 ZcmZo;?`5CxpIsrbSRpa5a^wGYCICS52TcF~ delta 11 ScmeBWZ)2bEe={3nI}-pI;sf*m diff --git a/app/soapbox/reducers/__tests__/push_notifications-test.js b/app/soapbox/reducers/__tests__/push_notifications.test.ts similarity index 93% rename from app/soapbox/reducers/__tests__/push_notifications-test.js rename to app/soapbox/reducers/__tests__/push_notifications.test.ts index a5db7131d70cd88c1d9a0bd2bb1d2070186ade89..e7080d42a7e4e44011a9085bf8891ff58acc1f97 100644 GIT binary patch delta 11 ScmbQvGMQzABI9IL#!mnhMFX$^ delta 15 WcmbQtGM#0EA|rENYWZXZ#?JsH4g~oC diff --git a/app/soapbox/reducers/__tests__/reports-test.js b/app/soapbox/reducers/__tests__/reports.test.ts similarity index 84% rename from app/soapbox/reducers/__tests__/reports-test.js rename to app/soapbox/reducers/__tests__/reports.test.ts index 975a7ec49db6f26d31dbc0efca972293a25f04e6..77148e572964222ed0ada0eeba0d01848de233f5 100644 GIT binary patch delta 17 Ycmey()WketI=ez*u|i^A<;3Yv06L2Y82|tP delta 9 QcmZo-{>?OD`owup02G@9y#N3J diff --git a/app/soapbox/reducers/__tests__/settings-test.js b/app/soapbox/reducers/__tests__/settings.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/settings-test.js rename to app/soapbox/reducers/__tests__/settings.test.ts diff --git a/app/soapbox/reducers/__tests__/sidebar-test.js b/app/soapbox/reducers/__tests__/sidebar.test.ts similarity index 63% rename from app/soapbox/reducers/__tests__/sidebar-test.js rename to app/soapbox/reducers/__tests__/sidebar.test.ts index 511325488f3202dbb3c4c3134a67446a579299da..83212335f1501d6c0e5fcb48b84c9b4e97963a57 100644 GIT binary patch delta 17 YcmX@gc!qJpbasWrVui%K%8AqU06J*~bN~PV delta 9 QcmX@Zc$9I%^ojHI02J>87ytkO diff --git a/app/soapbox/reducers/__tests__/soapbox-test.js b/app/soapbox/reducers/__tests__/soapbox.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/soapbox-test.js rename to app/soapbox/reducers/__tests__/soapbox.test.ts diff --git a/app/soapbox/reducers/__tests__/statuses-test.js b/app/soapbox/reducers/__tests__/statuses.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/statuses-test.js rename to app/soapbox/reducers/__tests__/statuses.test.ts diff --git a/app/soapbox/reducers/__tests__/trends-test.js b/app/soapbox/reducers/__tests__/trends.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/trends-test.js rename to app/soapbox/reducers/__tests__/trends.test.ts diff --git a/app/soapbox/reducers/__tests__/user_lists-test.js b/app/soapbox/reducers/__tests__/user_lists.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/user_lists-test.js rename to app/soapbox/reducers/__tests__/user_lists.test.ts diff --git a/app/soapbox/reducers/__tests__/verification-test.js b/app/soapbox/reducers/__tests__/verification.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/verification-test.js rename to app/soapbox/reducers/__tests__/verification.test.ts diff --git a/app/soapbox/utils/__tests__/accounts-test.js b/app/soapbox/utils/__tests__/accounts.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/accounts-test.js rename to app/soapbox/utils/__tests__/accounts.test.ts diff --git a/app/soapbox/utils/__tests__/base64-test.js b/app/soapbox/utils/__tests__/base64.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/base64-test.js rename to app/soapbox/utils/__tests__/base64.test.ts diff --git a/app/soapbox/utils/__tests__/colors-test.js b/app/soapbox/utils/__tests__/colors.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/colors-test.js rename to app/soapbox/utils/__tests__/colors.test.ts diff --git a/app/soapbox/utils/__tests__/features-test.js b/app/soapbox/utils/__tests__/features.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/features-test.js rename to app/soapbox/utils/__tests__/features.test.ts diff --git a/app/soapbox/utils/__tests__/html-test.js b/app/soapbox/utils/__tests__/html.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/html-test.js rename to app/soapbox/utils/__tests__/html.test.ts diff --git a/app/soapbox/utils/__tests__/phone-test.js b/app/soapbox/utils/__tests__/phone.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/phone-test.js rename to app/soapbox/utils/__tests__/phone.test.ts diff --git a/app/soapbox/utils/__tests__/status-test.js b/app/soapbox/utils/__tests__/status.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/status-test.js rename to app/soapbox/utils/__tests__/status.test.ts diff --git a/app/soapbox/utils/__tests__/tailwind-test.js b/app/soapbox/utils/__tests__/tailwind.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/tailwind-test.js rename to app/soapbox/utils/__tests__/tailwind.test.ts From e78108efe2b2e37901b22342959615d0cb907525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 12 Jun 2022 20:15:34 +0200 Subject: [PATCH 3/4] TypeScript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/components/profile-hover-card.tsx | 4 +- ...data_light.js => emoji_mart_data_light.ts} | Bin 896 -> 1009 bytes .../{emoji_picker.js => emoji_picker.ts} | Bin app/soapbox/features/filters/index.js | Bin 10453 -> 0 bytes app/soapbox/features/filters/index.tsx | 229 ++++++++++++++++++ app/soapbox/normalizers/filter.ts | 22 ++ app/soapbox/normalizers/index.ts | 1 + .../{custom_emojis.js => custom_emojis.ts} | Bin 1174 -> 1401 bytes app/soapbox/reducers/filters.ts | 23 ++ app/soapbox/reducers/filters.tsx | 25 -- app/soapbox/reducers/profile_hover_card.js | Bin 732 -> 0 bytes app/soapbox/reducers/profile_hover_card.ts | 36 +++ app/soapbox/selectors/index.ts | 12 +- app/soapbox/types/entities.ts | 3 + 14 files changed, 322 insertions(+), 33 deletions(-) rename app/soapbox/features/emoji/{emoji_mart_data_light.js => emoji_mart_data_light.ts} (67%) rename app/soapbox/features/emoji/{emoji_picker.js => emoji_picker.ts} (100%) delete mode 100644 app/soapbox/features/filters/index.js create mode 100644 app/soapbox/features/filters/index.tsx create mode 100644 app/soapbox/normalizers/filter.ts rename app/soapbox/reducers/{custom_emojis.js => custom_emojis.ts} (65%) create mode 100644 app/soapbox/reducers/filters.ts delete mode 100644 app/soapbox/reducers/filters.tsx delete mode 100644 app/soapbox/reducers/profile_hover_card.js create mode 100644 app/soapbox/reducers/profile_hover_card.ts diff --git a/app/soapbox/components/profile-hover-card.tsx b/app/soapbox/components/profile-hover-card.tsx index 8e5e281bd2..11de952f26 100644 --- a/app/soapbox/components/profile-hover-card.tsx +++ b/app/soapbox/components/profile-hover-card.tsx @@ -68,9 +68,9 @@ export const ProfileHoverCard: React.FC = ({ visible = true } const [popperElement, setPopperElement] = useState(null); const me = useAppSelector(state => state.me); - const accountId: string | undefined = useAppSelector(state => state.profile_hover_card.get('accountId', undefined)); + const accountId: string | undefined = useAppSelector(state => state.profile_hover_card.accountId || undefined); const account = useAppSelector(state => accountId && getAccount(state, accountId)); - const targetRef = useAppSelector(state => state.profile_hover_card.getIn(['ref', 'current']) as Element | null); + const targetRef = useAppSelector(state => state.profile_hover_card.ref?.current); const badges = account ? getBadges(account) : []; useEffect(() => { diff --git a/app/soapbox/features/emoji/emoji_mart_data_light.js b/app/soapbox/features/emoji/emoji_mart_data_light.ts similarity index 67% rename from app/soapbox/features/emoji/emoji_mart_data_light.js rename to app/soapbox/features/emoji/emoji_mart_data_light.ts index 4756c1a5de83630b5d822d4d26f345813f08f971..03bdbf765a86711603471f3507ffc0ed27f145a9 100644 GIT binary patch delta 182 zcmZo*|HwXJqg7^ZL4Hw*LTYY)R;F`)Zb4CMadB#jLRwLNu7bLrK3F_H87`r2%>~s_ zJz0=hltZBwqI9w~qcoE>*TfCZ#%M-ab8#i-=M_V(D7I1vN=?o$O0g*}Day=C*HK8! otF)V(#+bkuzxfzr2_su-1;{~@y_n7TxgczXl+?7u(j2fD06|VazW@LL delta 168 zcmey!-oQR#<772Pr~0DQ!qUv5R1I}K{nXt2tjzf2{M>?~)Z*gQ6m?B&uH^i@;u3{w zh0?stko?fR%(TqZ6u-pWRE1gvTLmQjP&M%-`SCy|NL73uP#MS=s5xL8ih;VS pYk^|=`U)wNmotWJ{=-}WVMo1q16R5y!J2EQLFk7Z~Q|K?#q?oSt-umn!30EJNVQ$20(%a>F!wqC@5Ff2mOeI!p z+IOowjbpa--(_J9Y>#ku6-T;748oehp8ismWtxoWD$Ju-B8)_?Kfjk{EbuXnt1Xt< z-umC~wWj*ZU-PueMs$;8RXL*f;;uGvhZvP~PCg^LmLiS{%>!SrHUg$f??z|#GA)la z?g4HB^Fj>v!84cv3U7^X(7fR+gFX0dppHyFT+p6mbV0#N=`yib#5cMQtGF~S1d7)c zJc@49JSqY@jKHI)mWItDjG{#%ZhP2G+LS@Z3ExK%y%D!ioqfz4@=@&g%s$R$xr^Q3 z^iE21$~Jje2*Xj_WfJ!4<7k$qUs)wil&!s$T30@Vyd7p7nGzW zt*Sgna)@^@b;ij@L`H{Ax)qC3ZbghN(08s!)OGMHa3RaZaL%e_ELZpPZjg0xf2%k( z`9m+cmMf)h?;UtVUA*78T#V#!`%g$sr#X8>U7W96E{1c26u)3s7kQtp9g;4tFTnvh zx+uYf(lu>lWZhBkJmEe^f-c57RuGt3T9gId$~dM-7GahNndL4iJCm9& zo(qxZX|G4QG+m5;;LU`Sk;cuHT6a~&_%wH2ur*CTcSY6W?__gRFZ!aQP1$wUl}>Xe z@7wC4CG6v@SG%~qRN5<39EPZd(<$kKs8Y4g4ycKHULZ=UI7V@M!(kGP^fN3xdvSh_ z$Is4bD-#sH!dZLzL@z#}OH zh4`pf4s{U^vv(ze^nJ>(vw++Mf2H{)sWN`Fzj{3RAj&~to&`f-1vUWmX54BDI(-Lg zFy0$%ecr>f?`jZvwu-}|us1@$E+UBv>H)9&Ge!dt457wwSi@tsF)U13n1@@W`Xg|j zq)P^?6IuKyeyvc8BSsU%c`M@}bV=7$vT6}Bf^~^H`LPkTR4|tnMd1Kk1MJKv+Ugym zcH3uO)x4lGuY@LUl)MXChjC%nyn^Mecm>B>agsAixWlZ@ef9B&GuGw^TVKlPby_9m zU}!WeH?o+p?Td*u|`G2cZk4M`Ma>TF!;AIN1k7OMB;Brj%3XM)H8>GS-EnS zFEt__D0TTR7-a)KtDegm9nH@iCB$9^Tc#$}Fm$BLiz=}w${LL>Li7l(N7Rf|X#0#j zA01J{Ge-;_YmkLr&BZh)7=y0lHf2sf|DvLYxHb;F)2zcOt(ba}RmElyFi~Jkb5L6I z)`nz#n>AT`yQfFrW{;@N!&APGN4Y^e8`YbY0`^V^Zm&Dg_ieAzy*^_;|9;&&9S$cz z7s&wK2ipF^i8%rYLl=hzz~sQL;6;!PCqT}t%|Iast^zt_>)bi8P4h&NC}}6$8HTo% z8`#Eh;v$Tp&JTPRtq9~sd1p%HLYOV@49)0k3BOrP^!XBqTBXx7S!$}WE} zlWFlaY-*bfUW0xOUBWRf`zA7#xsE`Uu-(uW+pOH#vCW)jtx=AQ=7AzwG&*)$-_7Rv zSN}>YWO^j70F9&?)z1P zF!}HR{pv%eU8g8Bqe*yIEw{3q?^XWRRZ>?3M@&e>m!bwUT2r3voR-QoD6Y0#7G|mh zA7$f5>_8e4H6HVTaUO8K4H_$4l;?q&a5UD^L>Ed=C8zM~M6C}d*G>>_dQ`JEAJKmL z&1V?EWJ%lw&q?k#n9Zt8-Ljg77u-=t>21=`Se9a2%=e0c#`?aF$dtN_|C6zcM>t8i z322gcn$Sf!{sza_d>hg?Qw6@Pv1iVJ&owZ1v3;lvKgO%kgD-c*=Zc4`Z4390L~t9w#pF?D z7#vtB0ht7bV%(c+J*hzR6(ggehu=L+he&>MQ(1YNVzeH&#kUx<;aT*cyynj3hQ4d? z&Ff(G097-d0jxAUH9@O8J8w&yZ>N`9MRX2mZfaaRF5c3Aj^a(A*F4Rt-k^J!@{LVx z-v4*?Jq+4=?;h2|RQI<00ToAp)A9|&Dz^;Bh3_<`I8KFIdv%U+`;Ml?yAq5`-!%85!>f^7euI(fS%@iU zEp_iVmCHi`3g^!G4z34v#N$V>Jez7}?g<(SwvN`1ojCc@2;Lx?QwaWelQaKy@9{Y%fa?7&UIy9*rEu@p zZMc92o%XA~SJxJM3$rji9Srmr3~q*MBI}%r%)od9$RA;RaB+v;vq1lrlp)^UAu3=4DCJvVFTDgT?BbxVCPq(681f-%MABT@iEl6FhSjk*);bn&H*)9=vz z->J-lSL)6BsocWvD%hKvf1dZ(^&J-a`s>aOpJ5`!cFd`;ZK$7|SLKhF|535gnG5?e zp`LjLgr8HP;a{rXL;+re%NvY3@8-dIfYI3%el+sY8#C#orRT;6{$WcvR(X5w*;!)f ze!vf2WT;+igyS_#$WOr(qp&tEC^S--h9*PMD$LS2LJ;sPV=A`MEb9v@X$G t91XX}XLxJGrn_qUIPuZ&w2qr { + const intl = useIntl(); + const dispatch = useAppDispatch(); + + const filters = useAppSelector((state) => state.filters); + + const [phrase, setPhrase] = useState(''); + const [expiresAt] = useState(''); + const [homeTimeline, setHomeTimeline] = useState(true); + const [publicTimeline, setPublicTimeline] = useState(false); + const [notifications, setNotifications] = useState(false); + const [conversations, setConversations] = useState(false); + const [irreversible, setIrreversible] = useState(false); + const [wholeWord, setWholeWord] = useState(true); + + // const handleSelectChange = e => { + // this.setState({ [e.target.name]: e.target.value }); + // }; + + const handleAddNew: React.FormEventHandler = e => { + e.preventDefault(); + const context = []; + + if (homeTimeline) { + context.push('home'); + } + if (publicTimeline) { + context.push('public'); + } + if (notifications) { + context.push('notifications'); + } + if (conversations) { + context.push('thread'); + } + + dispatch(createFilter(intl, phrase, expiresAt, context, wholeWord, irreversible)).then(() => { + return dispatch(fetchFilters()); + }).catch(error => { + dispatch(snackbar.error(intl.formatMessage(messages.create_error))); + }); + }; + + const handleFilterDelete: React.MouseEventHandler = e => { + dispatch(deleteFilter(intl, e.currentTarget.dataset.value)).then(() => { + return dispatch(fetchFilters()); + }).catch(() => { + dispatch(snackbar.error(intl.formatMessage(messages.delete_error))); + }); + }; + + useEffect(() => { + dispatch(fetchFilters()); + }, []); + + const emptyMessage = ; + + return ( + + + + +
    + + setPhrase(target.value)} + /> + + {/* + + */} + + + + + + + + +
    + setHomeTimeline(target.checked)} + /> + setPublicTimeline(target.checked)} + /> + setNotifications(target.checked)} + /> + setConversations(target.checked)} + /> +
    + +
    + + + setIrreversible(target.checked)} + /> + setWholeWord(target.checked)} + /> + + + + + +
    + + + + + + + {filters.map((filter, i) => ( +
    +
    +
    + + {filter.phrase} +
    +
    + + + {filter.context.map((context, i) => ( + {context} + ))} + +
    +
    + + + {filter.irreversible ? + : + + } + {filter.whole_word && + + } + +
    +
    +
    + + +
    +
    + ))} +
    +
    + ); +}; + +export default Filters; diff --git a/app/soapbox/normalizers/filter.ts b/app/soapbox/normalizers/filter.ts new file mode 100644 index 0000000000..5f2f579603 --- /dev/null +++ b/app/soapbox/normalizers/filter.ts @@ -0,0 +1,22 @@ +/** + * Filter normalizer: + * Converts API filters into our internal format. + * @see {@link https://docs.joinmastodon.org/entities/filter/} + */ +import { List as ImmutableList, Map as ImmutableMap, Record as ImmutableRecord, fromJS } from 'immutable'; + +// https://docs.joinmastodon.org/entities/filter/ +export const FilterRecord = ImmutableRecord({ + id: '', + phrase: '', + context: ImmutableList(), + whole_word: false, + expires_at: '', + irreversible: false, +}); + +export const normalizeFilter = (filter: Record) => { + return FilterRecord( + ImmutableMap(fromJS(filter)), + ); +}; \ No newline at end of file diff --git a/app/soapbox/normalizers/index.ts b/app/soapbox/normalizers/index.ts index d660df0f2a..b1b41e0d65 100644 --- a/app/soapbox/normalizers/index.ts +++ b/app/soapbox/normalizers/index.ts @@ -6,6 +6,7 @@ export { CardRecord, normalizeCard } from './card'; export { ChatRecord, normalizeChat } from './chat'; export { ChatMessageRecord, normalizeChatMessage } from './chat_message'; export { EmojiRecord, normalizeEmoji } from './emoji'; +export { FilterRecord, normalizeFilter } from './filter'; export { HistoryRecord, normalizeHistory } from './history'; export { InstanceRecord, normalizeInstance } from './instance'; export { ListRecord, normalizeList } from './list'; diff --git a/app/soapbox/reducers/custom_emojis.js b/app/soapbox/reducers/custom_emojis.ts similarity index 65% rename from app/soapbox/reducers/custom_emojis.js rename to app/soapbox/reducers/custom_emojis.ts index 7008d52343a845a7b636913b2eaca4ab81851a92..477e7cce9799c34f90229ef84b0cd67218d6ea14 100644 GIT binary patch delta 342 zcmbQn`IBpcg0OF5fkI-jf@f}SX-Q&IPAZVUQO=t&E;F|vzoo#D%h*zL^RqIGCwDXX`4pEVmZa(^B$pPK; + +const importFilters = (_state: State, filters: APIEntity[]): State => { + return ImmutableList(filters.map((filter) => normalizeFilter(filter))); +}; + +export default function filters(state: State = ImmutableList(), action: AnyAction): State { + switch (action.type) { + case FILTERS_FETCH_SUCCESS: + return importFilters(state, action.filters); + default: + return state; + } +} diff --git a/app/soapbox/reducers/filters.tsx b/app/soapbox/reducers/filters.tsx deleted file mode 100644 index e79dde0196..0000000000 --- a/app/soapbox/reducers/filters.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { - Map as ImmutableMap, - List as ImmutableList, - fromJS, -} from 'immutable'; - -import { FILTERS_FETCH_SUCCESS } from '../actions/filters'; - -import type { AnyAction } from 'redux'; - -type Filter = ImmutableMap; -type State = ImmutableList; - -const importFilters = (_state: State, filters: unknown): State => { - return ImmutableList(fromJS(filters)).map(filter => ImmutableMap(fromJS(filter))); -}; - -export default function filters(state: State = ImmutableList(), action: AnyAction): State { - switch (action.type) { - case FILTERS_FETCH_SUCCESS: - return importFilters(state, action.filters); - default: - return state; - } -} diff --git a/app/soapbox/reducers/profile_hover_card.js b/app/soapbox/reducers/profile_hover_card.js deleted file mode 100644 index 8020b965f2d423b7533bc7b86e8f4108914416e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 732 zcmah{(Qbk;6n*C_?p_2EgYPap7-iAK4Wrv$NiDat2~g6O&BgHVYbh8tn%$>z&+X|s z=fcZcNDU`=B{dKQtFmk~*%xTPTVPU@;PavBKYJeUZ+HNkZThlWC)qOnOt#s4wq0cD zCV3m*hvw^amps5eHjCN20f!frAoX4xCxmJ)DmAI4V7$QWAihy%l*rslp$5{xE3P>y zcA98}_{u>LnkhVX7IS2zDKxOA>PVsITw2PxVGLBya7j1@Cn1EBaixB^rUwXIFVep? zIskwYg^vQ6nya=X>PA-A3N5WGiEP@x7MZh6$`zqhG?iZEXZYM1hFW9P4nI=i^1ac~ z`Hd9n!0&R!+#iFM4gN#cEpp)E3|w&0*CkO1aU6GKFdD&A9~cvoVt6*z=h5kK`T?*| Wcsp?UQ`(hUr~Nty8Mjoe*Lr^to8hGZ diff --git a/app/soapbox/reducers/profile_hover_card.ts b/app/soapbox/reducers/profile_hover_card.ts new file mode 100644 index 0000000000..b07897715c --- /dev/null +++ b/app/soapbox/reducers/profile_hover_card.ts @@ -0,0 +1,36 @@ +import { Record as ImmutableRecord } from 'immutable'; + +import { + PROFILE_HOVER_CARD_OPEN, + PROFILE_HOVER_CARD_CLOSE, + PROFILE_HOVER_CARD_UPDATE, +} from 'soapbox/actions/profile_hover_card'; + +import type { AnyAction } from 'redux'; + +const ReducerRecord = ImmutableRecord({ + ref: null as React.MutableRefObject | null, + accountId: '', + hovered: false, +}); + +type State = ReturnType; + +export default function profileHoverCard(state: State = ReducerRecord(), action: AnyAction) { + switch (action.type) { + case PROFILE_HOVER_CARD_OPEN: + return state.withMutations((state) => { + state.set('ref', action.ref); + state.set('accountId', action.accountId); + }); + case PROFILE_HOVER_CARD_UPDATE: + return state.set('hovered', true); + case PROFILE_HOVER_CARD_CLOSE: + if (state.get('hovered') === true && !action.force) + return state; + else + return ReducerRecord(); + default: + return state; + } +} diff --git a/app/soapbox/selectors/index.ts b/app/soapbox/selectors/index.ts index 316517a559..c1160acd3a 100644 --- a/app/soapbox/selectors/index.ts +++ b/app/soapbox/selectors/index.ts @@ -14,7 +14,7 @@ import { shouldFilter } from 'soapbox/utils/timelines'; import type { ReducerChat } from 'soapbox/reducers/chats'; import type { RootState } from 'soapbox/store'; -import type { Notification } from 'soapbox/types/entities'; +import type { Filter as FilterEntity, Notification } from 'soapbox/types/entities'; const normalizeId = (id: any): string => typeof id === 'string' ? id : ''; @@ -104,18 +104,18 @@ const toServerSideType = (columnType: string): string => { type FilterContext = { contextType?: string }; export const getFilters = (state: RootState, query: FilterContext) => { - return state.filters.filter((filter): boolean => { + return state.filters.filter((filter) => { return query?.contextType - && filter.get('context').includes(toServerSideType(query.contextType)) - && (filter.get('expires_at') === null - || Date.parse(filter.get('expires_at')) > new Date().getTime()); + && filter.context.includes(toServerSideType(query.contextType)) + && (filter.expires_at === null + || Date.parse(filter.expires_at) > new Date().getTime()); }); }; const escapeRegExp = (string: string) => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string -export const regexFromFilters = (filters: ImmutableList>) => { +export const regexFromFilters = (filters: ImmutableList) => { if (filters.size === 0) return null; return new RegExp(filters.map(filter => { diff --git a/app/soapbox/types/entities.ts b/app/soapbox/types/entities.ts index 023139cefa..37572ae249 100644 --- a/app/soapbox/types/entities.ts +++ b/app/soapbox/types/entities.ts @@ -8,6 +8,7 @@ import { ChatMessageRecord, EmojiRecord, FieldRecord, + FilterRecord, HistoryRecord, InstanceRecord, ListRecord, @@ -31,6 +32,7 @@ type Chat = ReturnType; type ChatMessage = ReturnType; type Emoji = ReturnType; type Field = ReturnType; +type Filter = ReturnType; type History = ReturnType; type Instance = ReturnType; type List = ReturnType; @@ -68,6 +70,7 @@ export { ChatMessage, Emoji, Field, + Filter, History, Instance, List, From 7b5114a1b844189f00708916f78d484b625e4210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 12 Jun 2022 20:29:28 +0200 Subject: [PATCH 4/4] prefer TypeScript for tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../{compose.test.js => compose.test.ts} | Bin ...oji.test.js => autosuggest_emoji.test.tsx} | Bin 931 -> 945 bytes .../{avatar.test.js => avatar.test.tsx} | Bin ...verlay.test.js => avatar_overlay.test.tsx} | Bin .../{badge.test.js => badge.test.tsx} | Bin ...lay_name.test.js => display_name.test.tsx} | Bin ...lector.test.js => emoji_selector.test.tsx} | Bin ...ton.test.js => scroll-top-button.test.tsx} | Bin .../{captcha.test.js => captcha.test.tsx} | Bin ...login_form.test.js => login_form.test.tsx} | Bin ...login_page.test.js => login_page.test.tsx} | Bin .../{emoji_picker.ts => emoji_picker.js} | Bin ...button.test.js => compose-button.test.tsx} | Bin .../features/ui/components/list_panel.tsx | 2 +- ...tion.test.js => age-verification.test.tsx} | Bin ...on.test.js => email-verification.test.tsx} | Bin ...tion.test.js => sms-verification.test.tsx} | Bin .../{compose-test.js => compose.test.ts} | Bin 15219 -> 15183 bytes .../{contexts-test.js => contexts.test.ts} | Bin 3372 -> 3549 bytes ...{list_adder-test.js => list_adder.test.ts} | Bin 2621 -> 2652 bytes .../{modals-test.js => modals.test.ts} | Bin 1338 -> 1573 bytes app/soapbox/reducers/__tests__/mutes.test.ts | 4 ++++ .../{config_db-test.js => config_db.test.ts} | Bin 373 -> 418 bytes .../{numbers-test.tsx => numbers.test.tsx} | 0 24 files changed, 5 insertions(+), 1 deletion(-) rename app/soapbox/actions/__tests__/{compose.test.js => compose.test.ts} (100%) rename app/soapbox/components/__tests__/{autosuggest_emoji.test.js => autosuggest_emoji.test.tsx} (88%) rename app/soapbox/components/__tests__/{avatar.test.js => avatar.test.tsx} (100%) rename app/soapbox/components/__tests__/{avatar_overlay.test.js => avatar_overlay.test.tsx} (100%) rename app/soapbox/components/__tests__/{badge.test.js => badge.test.tsx} (100%) rename app/soapbox/components/__tests__/{display_name.test.js => display_name.test.tsx} (100%) rename app/soapbox/components/__tests__/{emoji_selector.test.js => emoji_selector.test.tsx} (100%) rename app/soapbox/components/__tests__/{scroll-top-button.test.js => scroll-top-button.test.tsx} (100%) rename app/soapbox/features/auth_login/components/__tests__/{captcha.test.js => captcha.test.tsx} (100%) rename app/soapbox/features/auth_login/components/__tests__/{login_form.test.js => login_form.test.tsx} (100%) rename app/soapbox/features/auth_login/components/__tests__/{login_page.test.js => login_page.test.tsx} (100%) rename app/soapbox/features/emoji/{emoji_picker.ts => emoji_picker.js} (100%) rename app/soapbox/features/ui/components/__tests__/{compose-button.test.js => compose-button.test.tsx} (100%) rename app/soapbox/features/verification/steps/__tests__/{age-verification.test.js => age-verification.test.tsx} (100%) rename app/soapbox/features/verification/steps/__tests__/{email-verification.test.js => email-verification.test.tsx} (100%) rename app/soapbox/features/verification/steps/__tests__/{sms-verification.test.js => sms-verification.test.tsx} (100%) rename app/soapbox/reducers/__tests__/{compose-test.js => compose.test.ts} (96%) rename app/soapbox/reducers/__tests__/{contexts-test.js => contexts.test.ts} (91%) rename app/soapbox/reducers/__tests__/{list_adder-test.js => list_adder.test.ts} (93%) rename app/soapbox/reducers/__tests__/{modals-test.js => modals.test.ts} (56%) rename app/soapbox/utils/__tests__/{config_db-test.js => config_db.test.ts} (61%) rename app/soapbox/utils/__tests__/{numbers-test.tsx => numbers.test.tsx} (100%) diff --git a/app/soapbox/actions/__tests__/compose.test.js b/app/soapbox/actions/__tests__/compose.test.ts similarity index 100% rename from app/soapbox/actions/__tests__/compose.test.js rename to app/soapbox/actions/__tests__/compose.test.ts diff --git a/app/soapbox/components/__tests__/autosuggest_emoji.test.js b/app/soapbox/components/__tests__/autosuggest_emoji.test.tsx similarity index 88% rename from app/soapbox/components/__tests__/autosuggest_emoji.test.js rename to app/soapbox/components/__tests__/autosuggest_emoji.test.tsx index 938ca737b2d6ce1beca00585202561a1dd00a045..8fab0ef8b0930f8db8847ee4869bf061f14e8ccb 100644 GIT binary patch delta 36 kcmZ3?zL9-{KO?(BVzEMEUgc(g#`$p0WPiri$;HeD0Mq6RZ2$lO delta 20 ZcmdnUzL state.lists], list return lists; } - return lists.toList().filter(item => !!item).sort((a, b) => (a as ListEntity).title.localeCompare((b as ListEntity).title)).take(4) as ImmutableList;; + return lists.toList().filter(item => !!item).sort((a, b) => (a as ListEntity).title.localeCompare((b as ListEntity).title)).take(4) as ImmutableList; }); const ListPanel = () => { diff --git a/app/soapbox/features/verification/steps/__tests__/age-verification.test.js b/app/soapbox/features/verification/steps/__tests__/age-verification.test.tsx similarity index 100% rename from app/soapbox/features/verification/steps/__tests__/age-verification.test.js rename to app/soapbox/features/verification/steps/__tests__/age-verification.test.tsx diff --git a/app/soapbox/features/verification/steps/__tests__/email-verification.test.js b/app/soapbox/features/verification/steps/__tests__/email-verification.test.tsx similarity index 100% rename from app/soapbox/features/verification/steps/__tests__/email-verification.test.js rename to app/soapbox/features/verification/steps/__tests__/email-verification.test.tsx diff --git a/app/soapbox/features/verification/steps/__tests__/sms-verification.test.js b/app/soapbox/features/verification/steps/__tests__/sms-verification.test.tsx similarity index 100% rename from app/soapbox/features/verification/steps/__tests__/sms-verification.test.js rename to app/soapbox/features/verification/steps/__tests__/sms-verification.test.tsx diff --git a/app/soapbox/reducers/__tests__/compose-test.js b/app/soapbox/reducers/__tests__/compose.test.ts similarity index 96% rename from app/soapbox/reducers/__tests__/compose-test.js rename to app/soapbox/reducers/__tests__/compose.test.ts index 1c4e709483e48752dc3121a35f63dddcb00dd9be..42c276cf6133925e5a9f910857a923e02a230160 100644 GIT binary patch delta 206 zcmexdcD_tLGq)hWs6?S!!6&o0L?N+Q!813vv?MVpClw^1vymfKmLEk(LvykrzuD$_ zvio_^B{s)vePEqjqoh80wn4^Zd26l76J$6h*BS{K|Ld}IHM#nU0op- zY$Q+<*JeH=F-EWn1;!yz6WAwjHxi#b+n8swh>12cSaO0H>*NXMN?-*I3LKjsm``Q~ E05Fh91ONa4 delta 124 zcmX?K_PLBBGq)hWs6?T9qkOC^bG1V4tuEjFtd$uWY}CGnU}&NL1IsoDI_*pC@5m~5^N O)_Bj1ZSz6%K4t)U2Q6O! diff --git a/app/soapbox/reducers/__tests__/contexts-test.js b/app/soapbox/reducers/__tests__/contexts.test.ts similarity index 91% rename from app/soapbox/reducers/__tests__/contexts-test.js rename to app/soapbox/reducers/__tests__/contexts.test.ts index d5270f0d8e5cd04d383d5fb877d5e7e6ed80b35b..90176309166c1003ec4e6e2e07359d89fe091e17 100644 GIT binary patch delta 214 zcmZ1@bys==3lqCSVzEMEUgc&MroEgBAdY8lZfQwkQckLGVu4L@Nl|8Ax{d;bwwrvA ryTTNwBDhZfqLkF4)Rf@V5~u-oc9Si6f`~ERcJc`xUNWt?$`cL%9wSZ* delta 42 rcmcaBy+&#S3)5z9roEh#UvO7Up2`yhq-}XMb+{CupjLBo8*exOGj9yh diff --git a/app/soapbox/reducers/__tests__/list_adder-test.js b/app/soapbox/reducers/__tests__/list_adder.test.ts similarity index 93% rename from app/soapbox/reducers/__tests__/list_adder-test.js rename to app/soapbox/reducers/__tests__/list_adder.test.ts index 4806d3d13908fb9e199293448246e3f180455b87..3989cf5e7027f0553f21f0b18c1d9eca0ac7f71a 100644 GIT binary patch delta 98 zcmdlhaz|u?JR`e8VzEMEUgc(aMo&f#o8pq9%)E5F$+fI{lli$gH_vA}izzyJK9k4h T*DU?mWhTF7;n~c}Zov!y8NVMH delta 50 zcmca3vR7n-Jmcg*_N9|gGcK82!)P;kKa2C`Z%nO>AkOCfESJCxps4?56?O||0RLVR A+5i9m diff --git a/app/soapbox/reducers/__tests__/modals-test.js b/app/soapbox/reducers/__tests__/modals.test.ts similarity index 56% rename from app/soapbox/reducers/__tests__/modals-test.js rename to app/soapbox/reducers/__tests__/modals.test.ts index 36f4fba64046e385b81013e87576360cae8978a1..bbb5c4552892a12e23f10190287f26b74b9efba1 100644 GIT binary patch delta 360 zcmdnRwUlRqoV1QYP-=31QHnxhv4UrAZfQwkQcfyFXrkO(c93vlUgczN#vE1~Aj58R zIim-oIF|w#plQ&U{E=B@vMZA^n}R~EriSL^0v4OemOvq1CJDya$u-QS0@!qzDJbOT zrzGYC6y+BbTPfs~=H%!=EdZGUV`I@OHF+NkhXu$fWE!9%hhHnu2US4VbF;b@mL}#* Ye!;A3fJXzwrLmgUK-bp-NiGlp05$AtP5=M^ delta 151 zcmZ3=vx{qj+(gT_lXV$$7&RsbGHY!<$tcUnRLwP+ky&B#dq$^{l&847F3naNf1ORz#F9iSq diff --git a/app/soapbox/reducers/__tests__/mutes.test.ts b/app/soapbox/reducers/__tests__/mutes.test.ts index 512a5260ff..411db10c68 100644 --- a/app/soapbox/reducers/__tests__/mutes.test.ts +++ b/app/soapbox/reducers/__tests__/mutes.test.ts @@ -42,6 +42,8 @@ describe('mutes reducer', () => { it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => { const state = ImmutableRecord({ new: ImmutableRecord({ + isSubmitting: false, + accountId: null, notifications: true, })(), })(); @@ -50,6 +52,8 @@ describe('mutes reducer', () => { }; expect(reducer(state, action).toJS()).toEqual({ new: { + isSubmitting: false, + accountId: null, notifications: false, }, }); diff --git a/app/soapbox/utils/__tests__/config_db-test.js b/app/soapbox/utils/__tests__/config_db.test.ts similarity index 61% rename from app/soapbox/utils/__tests__/config_db-test.js rename to app/soapbox/utils/__tests__/config_db.test.ts index b8ad15e0f5e45791760472345609463e20b6d16c..a83757eb35d4e222740418fd3b67e985df127957 100644 GIT binary patch delta 65 zcmey$w1`1}#VqT@)#4n8i D6pI+$ delta 20 bcmZ3){FR9#Gq)hWs6?T9qWqi5ij0i_P`3xI diff --git a/app/soapbox/utils/__tests__/numbers-test.tsx b/app/soapbox/utils/__tests__/numbers.test.tsx similarity index 100% rename from app/soapbox/utils/__tests__/numbers-test.tsx rename to app/soapbox/utils/__tests__/numbers.test.tsx