mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-06 00:16:58 +00:00
Add translations
This commit is contained in:
parent
8c4b5d27ed
commit
c849854f58
@ -449,6 +449,7 @@ export const ChatList = ({
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{enableMentions && (hasSecretKey || isPrivate === false) && (
|
||||
<ChatOptions
|
||||
openQManager={openQManager}
|
||||
|
@ -24,7 +24,6 @@ import {
|
||||
AppsSearchLeft,
|
||||
AppsSearchRight,
|
||||
} from '../Apps/Apps-styles';
|
||||
|
||||
import IconClearInput from '../../assets/svgs/ClearInput.svg';
|
||||
import { CellMeasurerCache } from 'react-virtualized';
|
||||
import { getBaseApiReact } from '../../App';
|
||||
@ -60,10 +59,12 @@ export const ChatOptions = ({
|
||||
const [searchValue, setSearchValue] = useState('');
|
||||
const [selectedMember, setSelectedMember] = useState(0);
|
||||
const theme = useTheme();
|
||||
const { t } = useTranslation(['auth', 'core', 'group']);
|
||||
const parentRef = useRef(null);
|
||||
const parentRefMentions = useRef(null);
|
||||
const [lastMentionTimestamp, setLastMentionTimestamp] = useState(null);
|
||||
const [debouncedValue, setDebouncedValue] = useState(''); // Debounced value
|
||||
|
||||
const messages = useMemo(() => {
|
||||
return untransformedMessages?.map((item) => {
|
||||
if (item?.messageText) {
|
||||
@ -80,7 +81,7 @@ export const ChatOptions = ({
|
||||
messageText: transformedMessage,
|
||||
};
|
||||
} catch (error) {
|
||||
// error
|
||||
console.log(error);
|
||||
}
|
||||
} else return item;
|
||||
});
|
||||
@ -102,7 +103,12 @@ export const ChatOptions = ({
|
||||
rej(response.error);
|
||||
})
|
||||
.catch((error) => {
|
||||
rej(error.message || 'An error occurred');
|
||||
rej(
|
||||
error.message ||
|
||||
t('core:message.error.generic', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
@ -154,6 +160,7 @@ export const ChatOptions = ({
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
if (selectedMember) {
|
||||
return messages
|
||||
.filter(
|
||||
@ -165,6 +172,7 @@ export const ChatOptions = ({
|
||||
)
|
||||
?.sort((a, b) => b?.timestamp - a?.timestamp);
|
||||
}
|
||||
|
||||
return messages
|
||||
.filter((message) =>
|
||||
extractTextFromHTML(
|
||||
@ -187,6 +195,7 @@ export const ChatOptions = ({
|
||||
)
|
||||
?.sort((a, b) => b?.timestamp - a?.timestamp);
|
||||
}
|
||||
|
||||
return messages
|
||||
.filter((message) =>
|
||||
extractTextFromHTML(message?.decryptedData?.message)?.includes(
|
||||
@ -251,6 +260,7 @@ export const ChatOptions = ({
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
alignItems: 'center',
|
||||
@ -268,9 +278,12 @@ export const ChatOptions = ({
|
||||
color: theme.palette.text.primary,
|
||||
}}
|
||||
>
|
||||
No results
|
||||
{t('core:message.generic.no_results', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
@ -416,6 +429,7 @@ export const ChatOptions = ({
|
||||
}}
|
||||
/>
|
||||
</AppsSearchLeft>
|
||||
|
||||
<AppsSearchRight>
|
||||
{searchValue && (
|
||||
<ButtonBase
|
||||
@ -428,6 +442,7 @@ export const ChatOptions = ({
|
||||
)}
|
||||
</AppsSearchRight>
|
||||
</AppsSearchContainer>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
alignItems: 'center',
|
||||
@ -445,8 +460,11 @@ export const ChatOptions = ({
|
||||
value={selectedMember}
|
||||
>
|
||||
<MenuItem value={0}>
|
||||
<em>By member</em>
|
||||
<em>
|
||||
{t('core:sort.by_member', { postProcess: 'capitalizeFirst' })}
|
||||
</em>
|
||||
</MenuItem>
|
||||
|
||||
{members?.map((member) => {
|
||||
return (
|
||||
<MenuItem key={member} value={member}>
|
||||
@ -455,6 +473,7 @@ export const ChatOptions = ({
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
|
||||
{!!selectedMember && (
|
||||
<CloseIcon
|
||||
onClick={() => {
|
||||
@ -476,9 +495,12 @@ export const ChatOptions = ({
|
||||
color: theme.palette.text.secondary,
|
||||
}}
|
||||
>
|
||||
No results
|
||||
{t('core:message.generic.no_results', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
@ -545,7 +567,9 @@ export const ChatOptions = ({
|
||||
<ErrorBoundary
|
||||
fallback={
|
||||
<Typography>
|
||||
Error loading content: Invalid Data
|
||||
{t('group.message.generic.invalid_data', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})}
|
||||
</Typography>
|
||||
}
|
||||
>
|
||||
@ -567,6 +591,7 @@ export const ChatOptions = ({
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@ -606,7 +631,7 @@ export const ChatOptions = ({
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
SEARCH
|
||||
{t('core:action.search', { postProcess: 'capitalizeAll' })}
|
||||
</span>
|
||||
}
|
||||
placement="left"
|
||||
@ -629,6 +654,7 @@ export const ChatOptions = ({
|
||||
<SearchIcon />
|
||||
</Tooltip>
|
||||
</ButtonBase>
|
||||
|
||||
<ButtonBase
|
||||
onClick={() => {
|
||||
setMode('default');
|
||||
@ -646,7 +672,7 @@ export const ChatOptions = ({
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
Q-MANAGER
|
||||
{t('core:q_apps.q_manager', { postProcess: 'capitalizeAll' })}
|
||||
</span>
|
||||
}
|
||||
placement="left"
|
||||
@ -669,6 +695,7 @@ export const ChatOptions = ({
|
||||
<InsertLinkIcon sx={{ color: theme.palette.text.primary }} />
|
||||
</Tooltip>
|
||||
</ButtonBase>
|
||||
|
||||
<ContextMenuMentions
|
||||
getTimestampMention={getTimestampMention}
|
||||
groupId={selectedGroup}
|
||||
@ -689,7 +716,9 @@ export const ChatOptions = ({
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
MENTIONED
|
||||
{t('core:message.generic.mentioned', {
|
||||
postProcess: 'capitalizeAll',
|
||||
})}
|
||||
</span>
|
||||
}
|
||||
placement="left"
|
||||
@ -768,6 +797,7 @@ const ShowMessage = ({ message, goToMessage, messages }) => {
|
||||
>
|
||||
{message?.senderName?.charAt(0)}
|
||||
</Avatar>
|
||||
|
||||
<Typography
|
||||
sx={{
|
||||
fontWight: 600,
|
||||
@ -788,6 +818,7 @@ const ShowMessage = ({ message, goToMessage, messages }) => {
|
||||
>
|
||||
{formatTimestamp(message.timestamp)}
|
||||
</Typography>
|
||||
|
||||
<Box
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
|
@ -18,6 +18,7 @@ import { base64ToUint8Array } from '../../qdn/encryption/group-encryption';
|
||||
import { uint8ArrayToObject } from '../../backgroundFunctions/encryption';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { txListAtom } from '../../atoms/global';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const CreateCommonSecret = ({
|
||||
groupId,
|
||||
@ -39,9 +40,9 @@ export const CreateCommonSecret = ({
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const theme = useTheme();
|
||||
const { t } = useTranslation(['auth', 'core', 'group']);
|
||||
|
||||
const getPublishesFromAdmins = async (admins: string[]) => {
|
||||
// const validApi = await findUsableApi();
|
||||
const queryString = admins.map((name) => `name=${name}`).join('&');
|
||||
const url = `${getBaseApiReact()}${getArbitraryEndpointReact()}?mode=ALL&service=DOCUMENT_PRIVATE&identifier=symmetric-qchat-group-${
|
||||
groupId
|
||||
@ -55,9 +56,11 @@ export const CreateCommonSecret = ({
|
||||
const filterId = adminData.filter(
|
||||
(data: any) => data.identifier === `symmetric-qchat-group-${groupId}`
|
||||
);
|
||||
|
||||
if (filterId?.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const sortedData = filterId.sort((a: any, b: any) => {
|
||||
// Get the most recent date for both a and b
|
||||
const dateA = a.updated ? new Date(a.updated) : new Date(a.created);
|
||||
@ -78,8 +81,13 @@ export const CreateCommonSecret = ({
|
||||
pauseAllQueues();
|
||||
|
||||
const { names } = await getGroupAdmins(groupId);
|
||||
|
||||
if (!names.length) {
|
||||
throw new Error('Network error');
|
||||
throw new Error(
|
||||
t('core:message.error.network_generic', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})
|
||||
);
|
||||
}
|
||||
const publish = await getPublishesFromAdmins(names);
|
||||
|
||||
@ -92,15 +100,18 @@ export const CreateCommonSecret = ({
|
||||
publish.identifier
|
||||
}?encoding=base64&rebuild=true`
|
||||
);
|
||||
|
||||
const data = await res.text();
|
||||
|
||||
const decryptedKey: any = await decryptResource(data);
|
||||
|
||||
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
||||
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
||||
|
||||
if (!validateSecretKey(decryptedKeyToObject))
|
||||
throw new Error('SecretKey is not valid');
|
||||
throw new Error(
|
||||
t('auth:message.error.invalid_secret_key', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})
|
||||
);
|
||||
|
||||
if (decryptedKeyToObject) {
|
||||
return decryptedKeyToObject;
|
||||
@ -113,17 +124,31 @@ export const CreateCommonSecret = ({
|
||||
const createCommonSecret = async () => {
|
||||
try {
|
||||
const fee = await getFee('ARBITRARY');
|
||||
|
||||
await show({
|
||||
message: 'Would you like to perform an ARBITRARY transaction?',
|
||||
message: t('core:question.perform_transaction', {
|
||||
action: 'ARBITRARY',
|
||||
postProcess: 'capitalizeFirst',
|
||||
}),
|
||||
publishFee: fee.fee + ' QORT',
|
||||
});
|
||||
setIsLoading(true);
|
||||
|
||||
const secretKey2 = await getSecretKey();
|
||||
|
||||
if (!secretKey2 && secretKey2 !== false)
|
||||
throw new Error('invalid secret key');
|
||||
throw new Error(
|
||||
t('auth:message.error.invalid_secret_key', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})
|
||||
);
|
||||
|
||||
if (secretKey2 && !validateSecretKey(secretKey2))
|
||||
throw new Error('invalid secret key');
|
||||
throw new Error(
|
||||
t('auth:message.error.invalid_secret_key', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
})
|
||||
);
|
||||
|
||||
const secretKeyToSend = !secretKey2 ? null : secretKey2;
|
||||
|
||||
@ -136,8 +161,9 @@ export const CreateCommonSecret = ({
|
||||
if (!response?.error) {
|
||||
setInfoSnack({
|
||||
type: 'success',
|
||||
message:
|
||||
'Successfully re-encrypted secret key. It may take a couple of minutes for the changes to propagate. Refresh the group in 5 mins.',
|
||||
message: t('auth:message.success.reencrypted_secret_key', {
|
||||
postProcess: 'capitalizeFirst',
|
||||
}),
|
||||
});
|
||||
setOpenSnack(true);
|
||||
setTxList((prev) => [
|
||||
|
@ -55,6 +55,7 @@
|
||||
"remove": "remove",
|
||||
"return_apps_dashboard": "return to Apps Dashboard",
|
||||
"save": "save",
|
||||
"search": "search",
|
||||
"search_apps": "search for apps",
|
||||
"select_app_type": "select App Type",
|
||||
"select_category": "select Category",
|
||||
@ -148,6 +149,7 @@
|
||||
"devmode_local_node": "please use your local node for dev mode! Logout and use Local node.",
|
||||
"fee_qort": "fee: {{ message }} QORT",
|
||||
"foreign_fee": "foreign fee: {{ message }}",
|
||||
"mentioned": "mentioned",
|
||||
"message_with_image": "this message already has an image",
|
||||
"name_available": "{{ name }} is available",
|
||||
"name_benefits": "benefits of a name",
|
||||
@ -218,6 +220,7 @@
|
||||
"q_apps": {
|
||||
"about": "about this Q-App",
|
||||
"q_mail": "q-mail",
|
||||
"q_manager": "q-manager",
|
||||
"q_sandbox": "q-Sandbox"
|
||||
},
|
||||
"question": {
|
||||
@ -234,6 +237,9 @@
|
||||
},
|
||||
"server": "server",
|
||||
"settings": "settings",
|
||||
"sort": {
|
||||
"by_member": "by member"
|
||||
},
|
||||
"supply": "supply",
|
||||
"tags": "tags",
|
||||
"theme": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user