diff --git a/src/assets/img/cid-blacklist.png b/src/assets/img/cid-blacklist.png new file mode 100644 index 0000000..9e88d86 Binary files /dev/null and b/src/assets/img/cid-blacklist.png differ diff --git a/src/components/Modals/FileBlackListModal.js b/src/components/Modals/FileBlackListModal.js index 27e233a..1808cc1 100644 --- a/src/components/Modals/FileBlackListModal.js +++ b/src/components/Modals/FileBlackListModal.js @@ -11,7 +11,6 @@ import isIPFS from 'is-ipfs'; const { TextArea } = Input; export default function EncryptFileModal({ color, closeModal, showModal = false }) { - const intl = useIntl(); const [loading, setLoading] = useState(false); const [isEdit, setIsEdit] = useState(false); @@ -20,8 +19,10 @@ export default function EncryptFileModal({ color, closeModal, showModal = false const [validateMsg, setValidateMsg] = useState(''); const getFileBlackListData = async () => { - let listData = await getFileBlackList() || []; - let listStr = listData.join('\n') || '' + setLoading(true); + let listData = (await getFileBlackList()) || []; + setLoading(false); + let listStr = listData.join('\n') || ''; setListVal(listStr); setInitListVal(listStr); }; @@ -44,7 +45,6 @@ export default function EncryptFileModal({ color, closeModal, showModal = false }, [showModal]); const validateCid = val => { - let res = isIPFS.cid(val); if (res) { setValidateMsg(''); @@ -85,25 +85,28 @@ export default function EncryptFileModal({ color, closeModal, showModal = false // if (listVal && !validateListVal(listVal)) { // return; // } + if(!listVal){ + setValidateMsg(t('validate_file_blacklist_cid1')) + return + } let listArr = listVal.split('\n'); let validateCids = true; - for (var v in listArr){ - if(listArr[v] && !validateCid(listArr[v])){ - validateCids = false + for (var v in listArr) { + if (listArr[v] && !validateCid(listArr[v])) { + validateCids = false; break; } - } - if(!validateCids){ + if (!validateCids) { setValidateMsg(t('validate_file_blacklist_cid2')); - return + return; } try { - await addFileBlackList(listArr,true); + await addFileBlackList(listArr, true); setLoading(false); setInitListVal(listVal); - setIsEdit(false) + setIsEdit(false); Emitter.emit('showMessageAlert', { message: 'add_file_blacklist_success', status: 'success', @@ -112,84 +115,76 @@ export default function EncryptFileModal({ color, closeModal, showModal = false } catch (e) { Emitter.emit('showMessageAlert', { message: e.Message, status: 'error' }); } - }; - return (
{t('file_blacklist_title')}
-
- {t('file_blacklist_desc')} -
+
{t('file_blacklist_desc')}
- {t('file_blacklist_desc2')} -
- - - -