Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3184795
D10094.id33986.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10094.id33986.diff
View Options
diff --git a/web/modals/keyserver-selection/add-keyserver-modal.react.js b/web/modals/keyserver-selection/add-keyserver-modal.react.js
--- a/web/modals/keyserver-selection/add-keyserver-modal.react.js
+++ b/web/modals/keyserver-selection/add-keyserver-modal.react.js
@@ -2,17 +2,32 @@
import * as React from 'react';
+import { addKeyserverActionType } from 'lib/actions/keyserver-actions.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
+import type { KeyserverInfo } from 'lib/types/keyserver-types.js';
+import { defaultConnectionInfo } from 'lib/types/socket-types.js';
+import { useDispatch } from 'lib/utils/redux-utils.js';
import css from './add-keyserver-modal.css';
import Button, { buttonThemes } from '../../components/button.react.js';
+import { useSelector } from '../../redux/redux-utils.js';
+import { useStaffCanSee } from '../../utils/staff-utils.js';
import Input from '../input.react.js';
import Modal from '../modal.react.js';
function AddKeyserverModal(): React.Node {
const { popModal } = useModalContext();
- const [keyserverURL, setKeyserverURL] = React.useState<string>('');
+ const dispatch = useDispatch();
+
+ const staffCanSee = useStaffCanSee();
+
+ const currentUserID = useSelector(state => state.currentUserInfo?.id);
+ const customServer = useSelector(state => state.customServer);
+
+ const [keyserverURL, setKeyserverURL] = React.useState<string>(
+ customServer && staffCanSee ? customServer : '',
+ );
const onChangeKeyserverURL = React.useCallback(
(event: SyntheticEvent<HTMLInputElement>) =>
@@ -21,8 +36,25 @@
);
const onClickAddKeyserver = React.useCallback(() => {
- // TODO
- }, []);
+ const newKeyserverInfo: KeyserverInfo = {
+ cookie: null,
+ updatesCurrentAsOf: 0,
+ urlPrefix: keyserverURL,
+ connection: defaultConnectionInfo,
+ lastCommunicatedPlatformDetails: null,
+ deviceToken: null,
+ };
+
+ dispatch({
+ type: addKeyserverActionType,
+ payload: {
+ keyserverAdminUserID: currentUserID,
+ newKeyserverInfo,
+ },
+ });
+
+ popModal();
+ }, [currentUserID, dispatch, keyserverURL, popModal]);
const addKeyserverModal = React.useMemo(
() => (
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 11:59 AM (18 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2451236
Default Alt Text
D10094.id33986.diff (2 KB)
Attached To
Mode
D10094: [web] implement onClickAddKeyserver callback
Attached
Detach File
Event Timeline
Log In to Comment