From be7eaff6f18039cfc146c453373e96b23ae7be27 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Wed, 24 Jun 2020 19:40:39 +0800 Subject: [PATCH] Add modal to remove uri from Blocked list. Issue 3800 --- static/app-strings.json | 6 ++-- ui/constants/modal_types.js | 1 + ui/modal/modalRemoveBlocked/index.js | 15 +++++++++ ui/modal/modalRemoveBlocked/view.jsx | 46 ++++++++++++++++++++++++++++ ui/modal/modalRouter/view.jsx | 3 ++ 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 ui/modal/modalRemoveBlocked/index.js create mode 100644 ui/modal/modalRemoveBlocked/view.jsx diff --git a/static/app-strings.json b/static/app-strings.json index e0c97848f..0b4e5c295 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -1201,7 +1201,7 @@ "%view_count% Views": "%view_count% Views", "Tap to unmute": "Tap to unmute", "Playing in %seconds_left% seconds...": "Playing in %seconds_left% seconds...", - "Autoplay timer paused.": "Autoplay timer paused.", + "Autoplay timer paused.": "Autoplay timer paused.", "0 Bytes": "0 Bytes", "Bytes": "Bytes", "KB": "KB", @@ -1257,5 +1257,7 @@ "Get notified when a publish or channel is confirmed.": "Get notified when a publish or channel is confirmed.", "Email Preferences": "Email Preferences", "Opt out of any topics you don't want to receive email about.": "Opt out of any topics you don't want to receive email about.", - "Uncheck your email below if you want to stop receiving messages.": "Uncheck your email below if you want to stop receiving messages." + "Uncheck your email below if you want to stop receiving messages.": "Uncheck your email below if you want to stop receiving messages.", + "Remove from Blocked List": "Remove from Blocked List", + "Are you sure you want to remove this from the list?": "Are you sure you want to remove this from the list?" } \ No newline at end of file diff --git a/ui/constants/modal_types.js b/ui/constants/modal_types.js index e8e36c3a2..474be314a 100644 --- a/ui/constants/modal_types.js +++ b/ui/constants/modal_types.js @@ -41,3 +41,4 @@ export const REPOST = 'repost'; export const SIGN_OUT = 'sign_out'; export const LIQUIDATE_SUPPORTS = 'liquidate_supports'; export const CONFIRM_AGE = 'confirm_age'; +export const REMOVE_BLOCKED = 'remove_blocked'; diff --git a/ui/modal/modalRemoveBlocked/index.js b/ui/modal/modalRemoveBlocked/index.js new file mode 100644 index 000000000..df24deff8 --- /dev/null +++ b/ui/modal/modalRemoveBlocked/index.js @@ -0,0 +1,15 @@ +import { connect } from 'react-redux'; +import { doHideModal } from 'redux/actions/app'; +import ModalRemoveBlocked from './view'; +import { doToggleBlockChannel, selectBlockedChannels } from 'lbry-redux'; + +const select = (state, props) => ({ + blockedChannels: selectBlockedChannels(state), +}); + +const perform = dispatch => ({ + closeModal: () => dispatch(doHideModal()), + toggleBlockChannel: uri => dispatch(doToggleBlockChannel(uri)), +}); + +export default connect(select, perform)(ModalRemoveBlocked); diff --git a/ui/modal/modalRemoveBlocked/view.jsx b/ui/modal/modalRemoveBlocked/view.jsx new file mode 100644 index 000000000..38d3b8a19 --- /dev/null +++ b/ui/modal/modalRemoveBlocked/view.jsx @@ -0,0 +1,46 @@ +// @flow +import React from 'react'; +import { Modal } from 'modal/modal'; +import I18nMessage from 'component/i18nMessage'; + +type Props = { + blockedUri: string, + closeModal: () => void, + blockedChannels: Array, + toggleBlockChannel: (uri: string) => void, +}; + +function ModalRemoveBlocked(props: Props) { + const { blockedUri, closeModal, blockedChannels, toggleBlockChannel } = props; + + function handleConfirm() { + if (blockedUri && blockedChannels.includes(blockedUri)) { + // DANGER: Always ensure the uri is actually in the list since we are using a + // toggle function. If 'null' is accidentally toggled INTO the list, the app + // won't start. Ideally, we should add a "removeBlockedChannel()", but with + // the gating above, it should be safe/good enough. + toggleBlockChannel(blockedUri); + } + + closeModal(); + } + + return ( + closeModal()} + > + {blockedUri} +

+

+ Are you sure you want to remove this from the list? +

+
+ ); +} + +export default ModalRemoveBlocked; diff --git a/ui/modal/modalRouter/view.jsx b/ui/modal/modalRouter/view.jsx index 475a2e461..cac5a8bc8 100644 --- a/ui/modal/modalRouter/view.jsx +++ b/ui/modal/modalRouter/view.jsx @@ -17,6 +17,7 @@ import ModalRevokeClaim from 'modal/modalRevokeClaim'; import ModalPhoneCollection from 'modal/modalPhoneCollection'; import ModalFirstSubscription from 'modal/modalFirstSubscription'; import ModalConfirmTransaction from 'modal/modalConfirmTransaction'; +import ModalRemoveBlocked from 'modal/modalRemoveBlocked'; import ModalSocialShare from 'modal/modalSocialShare'; import ModalSendTip from 'modal/modalSendTip'; import ModalPublish from 'modal/modalPublish'; @@ -140,6 +141,8 @@ function ModalRouter(props: Props) { return ; case MODALS.LIQUIDATE_SUPPORTS: return ; + case MODALS.REMOVE_BLOCKED: + return ; default: return null; }