mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-27 01:21:21 +00:00
Refactor loading translations
This commit is contained in:
parent
0759994891
commit
4f35730db6
@ -423,7 +423,7 @@ export const AnnouncementDiscussion = ({
|
|||||||
<LoadingSnackbar
|
<LoadingSnackbar
|
||||||
open={isLoading}
|
open={isLoading}
|
||||||
info={{
|
info={{
|
||||||
message: t('core:loading_comments', {
|
message: t('core:loading.comments', {
|
||||||
postProcess: 'capitalizeFirst',
|
postProcess: 'capitalizeFirst',
|
||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
import React, {
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
useCallback,
|
|
||||||
useEffect,
|
|
||||||
useMemo,
|
|
||||||
useReducer,
|
|
||||||
useRef,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
|
|
||||||
import { ChatList } from './ChatList';
|
import { ChatList } from './ChatList';
|
||||||
import Tiptap from './TipTap';
|
import Tiptap from './TipTap';
|
||||||
import { CustomButton } from '../../styles/App-styles';
|
import { CustomButton } from '../../styles/App-styles';
|
||||||
@ -31,9 +23,9 @@ import {
|
|||||||
} from '../../utils/events';
|
} from '../../utils/events';
|
||||||
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
||||||
import ShortUniqueId from 'short-unique-id';
|
import ShortUniqueId from 'short-unique-id';
|
||||||
import { ReturnIcon } from '../../assets/Icons/ReturnIcon';
|
|
||||||
import { ExitIcon } from '../../assets/Icons/ExitIcon';
|
import { ExitIcon } from '../../assets/Icons/ExitIcon';
|
||||||
import { ReplyPreview } from './MessageItem';
|
import { ReplyPreview } from './MessageItem';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const uid = new ShortUniqueId({ length: 5 });
|
const uid = new ShortUniqueId({ length: 5 });
|
||||||
|
|
||||||
@ -50,21 +42,20 @@ export const ChatDirect = ({
|
|||||||
setMobileViewModeKeepOpen,
|
setMobileViewModeKeepOpen,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const { t } = useTranslation(['auth', 'core', 'group']);
|
||||||
const { queueChats, addToQueue, processWithNewMessages } = useMessageQueue();
|
const { queueChats, addToQueue, processWithNewMessages } = useMessageQueue();
|
||||||
const [isFocusedParent, setIsFocusedParent] = useState(false);
|
const [isFocusedParent, setIsFocusedParent] = useState(false);
|
||||||
const [onEditMessage, setOnEditMessage] = useState(null);
|
const [onEditMessage, setOnEditMessage] = useState(null);
|
||||||
|
|
||||||
const [messages, setMessages] = useState([]);
|
const [messages, setMessages] = useState([]);
|
||||||
const [isSending, setIsSending] = useState(false);
|
const [isSending, setIsSending] = useState(false);
|
||||||
const [directToValue, setDirectToValue] = useState('');
|
const [directToValue, setDirectToValue] = useState('');
|
||||||
const hasInitialized = useRef(false);
|
const hasInitialized = useRef(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [openSnack, setOpenSnack] = React.useState(false);
|
const [openSnack, setOpenSnack] = useState(false);
|
||||||
const [infoSnack, setInfoSnack] = React.useState(null);
|
const [infoSnack, setInfoSnack] = useState(null);
|
||||||
const [publicKeyOfRecipient, setPublicKeyOfRecipient] = React.useState('');
|
const [publicKeyOfRecipient, setPublicKeyOfRecipient] = useState('');
|
||||||
const hasInitializedWebsocket = useRef(false);
|
const hasInitializedWebsocket = useRef(false);
|
||||||
const [chatReferences, setChatReferences] = useState({});
|
const [chatReferences, setChatReferences] = useState({});
|
||||||
|
|
||||||
const editorRef = useRef(null);
|
const editorRef = useRef(null);
|
||||||
const socketRef = useRef(null);
|
const socketRef = useRef(null);
|
||||||
const timeoutIdRef = useRef(null);
|
const timeoutIdRef = useRef(null);
|
||||||
@ -74,12 +65,8 @@ export const ChatDirect = ({
|
|||||||
const setEditorRef = (editorInstance) => {
|
const setEditorRef = (editorInstance) => {
|
||||||
editorRef.current = editorInstance;
|
editorRef.current = editorInstance;
|
||||||
};
|
};
|
||||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
||||||
|
|
||||||
const triggerRerender = () => {
|
|
||||||
forceUpdate(); // Trigger re-render by updating the state
|
|
||||||
};
|
|
||||||
const publicKeyOfRecipientRef = useRef(null);
|
const publicKeyOfRecipientRef = useRef(null);
|
||||||
|
|
||||||
const getPublicKeyFunc = async (address) => {
|
const getPublicKeyFunc = async (address) => {
|
||||||
try {
|
try {
|
||||||
const publicKey = await getPublicKey(address);
|
const publicKey = await getPublicKey(address);
|
||||||
@ -229,7 +216,12 @@ export const ChatDirect = ({
|
|||||||
rej(response.error);
|
rej(response.error);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
rej(error.message || 'An error occurred');
|
rej(
|
||||||
|
error.message ||
|
||||||
|
t('core:message.error.generic', {
|
||||||
|
postProcess: 'capitalizeFirst',
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -397,11 +389,20 @@ export const ChatDirect = ({
|
|||||||
rej(response.error);
|
rej(response.error);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
rej(error.message || 'An error occurred');
|
rej(
|
||||||
|
error.message ||
|
||||||
|
t('core:message.error.generic', {
|
||||||
|
postProcess: 'capitalizeFirst',
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error);
|
if (error instanceof Error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
} else {
|
||||||
|
throw new Error(String(error));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const clearEditorContent = () => {
|
const clearEditorContent = () => {
|
||||||
@ -432,8 +433,14 @@ export const ChatDirect = ({
|
|||||||
try {
|
try {
|
||||||
if (messageSize > 4000) return;
|
if (messageSize > 4000) return;
|
||||||
|
|
||||||
|
// TODO set magic number in a proper file
|
||||||
if (+balance < 4)
|
if (+balance < 4)
|
||||||
throw new Error('You need at least 4 QORT to send a message');
|
throw new Error(
|
||||||
|
t('group:message.error.qortals_required', {
|
||||||
|
quantity: 4,
|
||||||
|
postProcess: 'capitalizeFirst',
|
||||||
|
})
|
||||||
|
);
|
||||||
if (isSending) return;
|
if (isSending) return;
|
||||||
if (editorRef.current) {
|
if (editorRef.current) {
|
||||||
const htmlContent = editorRef.current.getHTML();
|
const htmlContent = editorRef.current.getHTML();
|
||||||
@ -500,7 +507,10 @@ export const ChatDirect = ({
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
message:
|
message:
|
||||||
errorMsg === 'invalid signature'
|
errorMsg === 'invalid signature'
|
||||||
? 'You need at least 4 QORT to send a message'
|
? t('group:message.error.qortals_required', {
|
||||||
|
quantity: 4,
|
||||||
|
postProcess: 'capitalizeFirst',
|
||||||
|
})
|
||||||
: errorMsg,
|
: errorMsg,
|
||||||
});
|
});
|
||||||
setOpenSnack(true);
|
setOpenSnack(true);
|
||||||
@ -566,13 +576,14 @@ export const ChatDirect = ({
|
|||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Close Direct Chat
|
{t('core:action.close_chat', { postProcess: 'capitalizeFirst' })}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{isNewChat && (
|
{isNewChat && (
|
||||||
<>
|
<>
|
||||||
<Spacer height="30px" />
|
<Spacer height="30px" />
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
sx={{
|
sx={{
|
||||||
fontSize: '18px',
|
fontSize: '18px',
|
||||||
@ -686,13 +697,19 @@ export const ChatDirect = ({
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
<Typography // TODO set magic number in a proper file
|
||||||
sx={{
|
sx={{
|
||||||
fontSize: '12px',
|
fontSize: '12px',
|
||||||
color:
|
color:
|
||||||
messageSize > 4000 ? theme.palette.other.danger : 'unset',
|
messageSize > 4000 ? theme.palette.other.danger : 'unset',
|
||||||
}}
|
}}
|
||||||
>{`Your message size is of ${messageSize} bytes out of a maximum of 4000`}</Typography>
|
>
|
||||||
|
{t('core:message.error.message_size', {
|
||||||
|
maximum: 4000,
|
||||||
|
size: messageSize,
|
||||||
|
postProcess: 'capitalizeFirst',
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -746,7 +763,7 @@ export const ChatDirect = ({
|
|||||||
<LoadingSnackbar
|
<LoadingSnackbar
|
||||||
open={isLoading}
|
open={isLoading}
|
||||||
info={{
|
info={{
|
||||||
message: 'Loading chat... please wait.',
|
message: t('core:loading.chat', { postProcess: 'capitalizeFirst' }),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -1073,7 +1073,7 @@ export const Thread = ({
|
|||||||
<LoadingSnackbar
|
<LoadingSnackbar
|
||||||
open={isLoading}
|
open={isLoading}
|
||||||
info={{
|
info={{
|
||||||
message: t('core:loading_posts', { postProcess: 'capitalizeFirst' }),
|
message: t('core:loading.posts', { postProcess: 'capitalizeFirst' }),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</GroupContainer>
|
</GroupContainer>
|
||||||
|
@ -76,7 +76,7 @@ export const ThingsToDoInitial = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!isLoaded
|
{!isLoaded
|
||||||
? t('core:loading', { postProcess: 'capitalizeFirst' })
|
? t('core:loading.generic', { postProcess: 'capitalizeFirst' })
|
||||||
: t('tutorial:initial.getting_started', {
|
: t('tutorial:initial.getting_started', {
|
||||||
postProcess: 'capitalizeFirst',
|
postProcess: 'capitalizeFirst',
|
||||||
})}
|
})}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"choose": "choose",
|
"choose": "choose",
|
||||||
"choose_file": "choose file",
|
"choose_file": "choose file",
|
||||||
"close": "close",
|
"close": "close",
|
||||||
|
"close_chat": "close Direct Chat",
|
||||||
"continue": "continue",
|
"continue": "continue",
|
||||||
"continue_logout": "continue to logout",
|
"continue_logout": "continue to logout",
|
||||||
"copy_link": "copy link",
|
"copy_link": "copy link",
|
||||||
@ -106,9 +107,12 @@
|
|||||||
"join_request": "join request list",
|
"join_request": "join request list",
|
||||||
"member": "member list"
|
"member": "member list"
|
||||||
},
|
},
|
||||||
"loading": "loading...",
|
"loading": {
|
||||||
"loading_comments": "loading comments... please wait.",
|
"generic": "loading...",
|
||||||
"loading_posts": "loading posts... please wait.",
|
"chat": "loading chat... please wait.",
|
||||||
|
"comments": "loading comments... please wait.",
|
||||||
|
"posts": "loading posts... please wait."
|
||||||
|
},
|
||||||
"message_us": "please message us on Telegram or Discord if you need 4 QORT to start chatting without any limitations",
|
"message_us": "please message us on Telegram or Discord if you need 4 QORT to start chatting without any limitations",
|
||||||
"message": {
|
"message": {
|
||||||
"error": {
|
"error": {
|
||||||
@ -116,7 +120,9 @@
|
|||||||
"app_need_name": "your app needs a name",
|
"app_need_name": "your app needs a name",
|
||||||
"file_too_large": "file {{ filename }} is too large. Max size allowed is {{ size }} MB.",
|
"file_too_large": "file {{ filename }} is too large. Max size allowed is {{ size }} MB.",
|
||||||
"generic": "an error occurred",
|
"generic": "an error occurred",
|
||||||
|
"invalid_signature": "invalid signature",
|
||||||
"invalid_zip": "invalid zip",
|
"invalid_zip": "invalid zip",
|
||||||
|
"message_size": "your message size is of {{ size }} bytes out of a maximum of {{ maximum }}",
|
||||||
"minting_account_add": "unable to add minting account",
|
"minting_account_add": "unable to add minting account",
|
||||||
"minting_account_remove": "unable to remove minting account",
|
"minting_account_remove": "unable to remove minting account",
|
||||||
"missing_fields": "missing: {{ fields }}",
|
"missing_fields": "missing: {{ fields }}",
|
||||||
|
@ -94,6 +94,7 @@
|
|||||||
"group_secret_key": "cannot get group secret key",
|
"group_secret_key": "cannot get group secret key",
|
||||||
"name_required": "please provide a name",
|
"name_required": "please provide a name",
|
||||||
"notify_admins": "try notifying an admin from the list of admins below:",
|
"notify_admins": "try notifying an admin from the list of admins below:",
|
||||||
|
"qortals_required": "you need at least {{ quantity }} QORT to send a message",
|
||||||
"timeout_reward": "timeout waiting for reward share confirmation",
|
"timeout_reward": "timeout waiting for reward share confirmation",
|
||||||
"thread_id": "unable to locate thread Id",
|
"thread_id": "unable to locate thread Id",
|
||||||
"unable_minting": "unable to start minting"
|
"unable_minting": "unable to start minting"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user