Provide temporary fix for communication with old server
Change-Id: I74c986b7d7892e4051908c9ee751f701ff4f4b9c
diff --git a/client/src/pages/AccountSelection.tsx b/client/src/pages/AccountSelection.tsx
index 35aed97..708f1eb 100644
--- a/client/src/pages/AccountSelection.tsx
+++ b/client/src/pages/AccountSelection.tsx
@@ -39,6 +39,8 @@
const [error, setError] = useState(false);
const [accounts, setAccounts] = useState<Account[]>([]);
+ authManager.authenticate('admin', 'admin');
+
useEffect(() => {
const controller = new AbortController();
authManager
@@ -77,7 +79,7 @@
<ListItemLink
key={account.getId()}
icon={<ConversationAvatar displayName={account.getDisplayNameNoFallback()} />}
- to={`/account/${account.getId()}/settings`}
+ to={`/deprecated-account/${account.getId()}/settings`}
primary={account.getDisplayName()}
secondary={account.getDisplayUri()}
/>
diff --git a/client/src/pages/AddContactPage.tsx b/client/src/pages/AddContactPage.tsx
index 666625c..b0dfad0 100644
--- a/client/src/pages/AddContactPage.tsx
+++ b/client/src/pages/AddContactPage.tsx
@@ -53,7 +53,7 @@
console.log(response);
if (response.conversationId) {
- navigate(`/account/${accountId}/conversation/${response.conversationId}`);
+ navigate(`/deprecated-account/${accountId}/conversation/${response.conversationId}`);
}
};
diff --git a/client/src/pages/DeprecatedAccountSettings.tsx b/client/src/pages/DeprecatedAccountSettings.tsx
new file mode 100644
index 0000000..4a37cd9
--- /dev/null
+++ b/client/src/pages/DeprecatedAccountSettings.tsx
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2022 Savoir-faire Linux Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program. If not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+import { CircularProgress, Container } from '@mui/material';
+import { Account } from 'jami-web-common';
+import { useEffect, useState } from 'react';
+import { useParams } from 'react-router';
+
+import authManager from '../AuthManager';
+import AccountPreferences from '../components/AccountPreferences';
+import Header from '../components/Header';
+import { setAccount, setAccountId } from '../redux/appSlice';
+import { useAppDispatch } from '../redux/hooks';
+
+type AccountSettingsProps = {
+ accountId?: string;
+ account?: Account;
+};
+
+const DeprecatedAccountSettings = (props: AccountSettingsProps) => {
+ console.log('ACCOUNT SETTINGS', props.account);
+ const params = useParams();
+ const accountId = props.accountId || params.accountId;
+
+ if (accountId == null) {
+ throw new Error('Missing accountId');
+ }
+
+ const dispatch = useAppDispatch();
+
+ const [localAccount, setLocalAccount] = useState<Account | null>(null);
+
+ useEffect(() => {
+ dispatch(setAccountId(accountId));
+
+ const controller = new AbortController();
+ authManager
+ .fetch(`/api/accounts/${accountId}`, { signal: controller.signal })
+ .then((res) => res.json())
+ .then((result) => {
+ console.log(result);
+ const account = Account.from(result);
+ account.setDevices(result.devices);
+ dispatch(setAccount(account));
+ setLocalAccount(account);
+ })
+ .catch((e) => console.log(e));
+ // return () => controller.abort() // crash on React18
+ }, [accountId, dispatch]);
+
+ return (
+ <Container maxWidth="sm">
+ <Header />
+ {localAccount != null ? <AccountPreferences account={localAccount} /> : <CircularProgress />}
+ </Container>
+ );
+};
+
+export default DeprecatedAccountSettings;