mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-07-23 04:36:52 +00:00
Translate newThread
This commit is contained in:
@@ -203,8 +203,11 @@ export const NewThread = ({
|
||||
// if (!description) missingFields.push('subject')
|
||||
if (missingFields.length > 0) {
|
||||
const missingFieldsString = missingFields.join(', ');
|
||||
const errMsg = `Missing: ${missingFieldsString}`;
|
||||
errorMsg = errMsg; // TODO translate
|
||||
const errMsg = t('group:message.error.missing_field', {
|
||||
field: missingFieldsString,
|
||||
postProcess: 'capitalize',
|
||||
});
|
||||
errorMsg = errMsg;
|
||||
}
|
||||
|
||||
if (errorMsg) {
|
||||
@@ -213,8 +216,12 @@ export const NewThread = ({
|
||||
|
||||
const htmlContent = editorRef.current.getHTML();
|
||||
|
||||
if (!htmlContent?.trim() || htmlContent?.trim() === '<p></p>')
|
||||
throw new Error('Please provide a first message to the thread');
|
||||
if (!htmlContent?.trim() || htmlContent?.trim() === '<p></p>') {
|
||||
const errMsg = t('group:message.generic.provide_message', {
|
||||
postProcess: 'capitalize',
|
||||
});
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
const fee = await getFee('ARBITRARY');
|
||||
let feeToShow = fee.fee;
|
||||
@@ -237,6 +244,7 @@ export const NewThread = ({
|
||||
delete reply.reply;
|
||||
}
|
||||
}
|
||||
|
||||
const mailObject: any = {
|
||||
createdAt: Date.now(),
|
||||
version: 1,
|
||||
@@ -249,7 +257,10 @@ export const NewThread = ({
|
||||
const secretKey =
|
||||
isPrivate === false ? null : await getSecretKey(false, true);
|
||||
if (!secretKey && isPrivate) {
|
||||
throw new Error('Cannot get group secret key');
|
||||
const errMsg = t('group:message.error.group_secret_key', {
|
||||
postProcess: 'capitalize',
|
||||
});
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
if (!isMessage) {
|
||||
@@ -272,17 +283,18 @@ export const NewThread = ({
|
||||
isPrivate === false
|
||||
? threadToBase64
|
||||
: await encryptSingleFunc(threadToBase64, secretKey);
|
||||
let identifierThread = `grp-${groupInfo.groupId}-thread-${idThread}`;
|
||||
const identifierThread = `grp-${groupInfo.groupId}-thread-${idThread}`;
|
||||
await publishGroupEncryptedResource({
|
||||
identifier: identifierThread,
|
||||
encryptedData: encryptSingleThread,
|
||||
});
|
||||
|
||||
let identifierPost = `thmsg-${identifierThread}-${idMsg}`;
|
||||
const identifierPost = `thmsg-${identifierThread}-${idMsg}`;
|
||||
await publishGroupEncryptedResource({
|
||||
identifier: identifierPost,
|
||||
encryptedData: encryptSingleFirstPost,
|
||||
});
|
||||
|
||||
const dataToSaveToStorage = {
|
||||
name: myName,
|
||||
identifier: identifierThread,
|
||||
@@ -291,6 +303,7 @@ export const NewThread = ({
|
||||
created: Date.now(),
|
||||
groupId: groupInfo.groupId,
|
||||
};
|
||||
|
||||
const dataToSaveToStoragePost = {
|
||||
name: myName,
|
||||
identifier: identifierPost,
|
||||
@@ -299,6 +312,7 @@ export const NewThread = ({
|
||||
created: Date.now(),
|
||||
threadId: identifierThread,
|
||||
};
|
||||
|
||||
await saveTempPublish({ data: dataToSaveToStorage, key: 'thread' });
|
||||
await saveTempPublish({
|
||||
data: dataToSaveToStoragePost,
|
||||
@@ -306,36 +320,32 @@ export const NewThread = ({
|
||||
});
|
||||
setInfoSnack({
|
||||
type: 'success',
|
||||
message:
|
||||
'Successfully created thread. It may take some time for the publish to propagate',
|
||||
message: t('group:message.success.thread_creation', {
|
||||
postProcess: 'capitalize',
|
||||
}),
|
||||
});
|
||||
setOpenSnack(true);
|
||||
|
||||
// dispatch(
|
||||
// setNotification({
|
||||
// msg: "Message sent",
|
||||
// alertType: "success",
|
||||
// })
|
||||
// );
|
||||
if (publishCallback) {
|
||||
publishCallback();
|
||||
}
|
||||
closeModal();
|
||||
} else {
|
||||
if (!currentThread) throw new Error('unable to locate thread Id');
|
||||
if (!currentThread) {
|
||||
const errMsg = t('group:message.error.thread_id', {
|
||||
postProcess: 'capitalize',
|
||||
});
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
const idThread = currentThread.threadId;
|
||||
const messageToBase64 = await objectToBase64(mailObject);
|
||||
const encryptSinglePost =
|
||||
isPrivate === false
|
||||
? messageToBase64
|
||||
: await encryptSingleFunc(messageToBase64, secretKey);
|
||||
const idMsg = uid.rnd();
|
||||
let identifier = `thmsg-${idThread}-${idMsg}`;
|
||||
const res = await publishGroupEncryptedResource({
|
||||
identifier: identifier,
|
||||
encryptedData: encryptSinglePost,
|
||||
});
|
||||
|
||||
const idMsg = uid.rnd();
|
||||
const identifier = `thmsg-${idThread}-${idMsg}`;
|
||||
const dataToSaveToStoragePost = {
|
||||
threadId: idThread,
|
||||
name: myName,
|
||||
@@ -348,32 +358,17 @@ export const NewThread = ({
|
||||
data: dataToSaveToStoragePost,
|
||||
key: 'thread-post',
|
||||
});
|
||||
// await qortalRequest(multiplePublishMsg);
|
||||
// dispatch(
|
||||
// setNotification({
|
||||
// msg: "Message sent",
|
||||
// alertType: "success",
|
||||
// })
|
||||
// );
|
||||
setInfoSnack({
|
||||
type: 'success',
|
||||
message:
|
||||
'Successfully created post. It may take some time for the publish to propagate',
|
||||
message: t('group:message.success.post_creation', {
|
||||
postProcess: 'capitalize',
|
||||
}),
|
||||
});
|
||||
setOpenSnack(true);
|
||||
if (publishCallback) {
|
||||
publishCallback();
|
||||
}
|
||||
// messageCallback({
|
||||
// identifier,
|
||||
// id: identifier,
|
||||
// name,
|
||||
// service: MAIL_SERVICE_TYPE,
|
||||
// created: Date.now(),
|
||||
// ...mailObject,
|
||||
// });
|
||||
}
|
||||
|
||||
closeModal();
|
||||
} catch (error: any) {
|
||||
if (error?.message) {
|
||||
@@ -392,6 +387,7 @@ export const NewThread = ({
|
||||
const sendMail = () => {
|
||||
publishQDNResource();
|
||||
};
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -406,7 +402,15 @@ export const NewThread = ({
|
||||
onClick={() => setIsOpen(true)}
|
||||
>
|
||||
<ComposeIcon />
|
||||
<ComposeP>{currentThread ? 'New Post' : 'New Thread'}</ComposeP>
|
||||
<ComposeP>
|
||||
{currentThread
|
||||
? t('core:action.new.post', {
|
||||
postProcess: 'capitalize',
|
||||
})
|
||||
: t('core:action.new.thread', {
|
||||
postProcess: 'capitalize',
|
||||
})}
|
||||
</ComposeP>
|
||||
</ComposeContainer>
|
||||
|
||||
<ReusableModal
|
||||
@@ -432,8 +436,15 @@ export const NewThread = ({
|
||||
}}
|
||||
>
|
||||
<NewMessageHeaderP>
|
||||
{isMessage ? 'Post Message' : 'New Thread'}
|
||||
{isMessage
|
||||
? t('core:action.post_message', {
|
||||
postProcess: 'capitalize',
|
||||
})
|
||||
: t('core:action.new.thread', {
|
||||
postProcess: 'capitalize',
|
||||
})}
|
||||
</NewMessageHeaderP>
|
||||
|
||||
<CloseContainer
|
||||
sx={{
|
||||
height: '40px',
|
||||
@@ -447,6 +458,7 @@ export const NewThread = ({
|
||||
/>
|
||||
</CloseContainer>
|
||||
</InstanceListHeader>
|
||||
|
||||
<InstanceListContainer
|
||||
sx={{
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
@@ -458,6 +470,7 @@ export const NewThread = ({
|
||||
{!isMessage && (
|
||||
<>
|
||||
<Spacer height="10px" />
|
||||
|
||||
<NewMessageInputRow>
|
||||
<Input
|
||||
id="standard-adornment-name"
|
||||
@@ -520,22 +533,22 @@ export const NewThread = ({
|
||||
|
||||
<InstanceFooter
|
||||
sx={{
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
padding: '20px 42px',
|
||||
alignItems: 'center',
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
height: '90px',
|
||||
padding: '20px 42px',
|
||||
}}
|
||||
>
|
||||
<NewMessageSendButton onClick={sendMail}>
|
||||
{isSending && (
|
||||
<Box
|
||||
sx={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
position: 'absolute',
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<CircularProgress
|
||||
@@ -548,7 +561,13 @@ export const NewThread = ({
|
||||
)}
|
||||
|
||||
<NewMessageSendP>
|
||||
{isMessage ? 'Post' : 'Create Thread'}
|
||||
{isMessage
|
||||
? t('core:action.post', {
|
||||
postProcess: 'capitalize',
|
||||
})
|
||||
: t('core:action.create_thread', {
|
||||
postProcess: 'capitalize',
|
||||
})}
|
||||
</NewMessageSendP>
|
||||
|
||||
{isMessage ? (
|
||||
|
@@ -36,7 +36,7 @@ export const NewUsersCTA = ({ balance }) => {
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
{t('core:new_user', { postProcess: 'capitalize' })}
|
||||
{t('core:question.new_user', { postProcess: 'capitalize' })}
|
||||
</Typography>
|
||||
|
||||
<Spacer height="20px" />
|
||||
|
Reference in New Issue
Block a user