mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-15 12:50:47 +02:00
Add frontend switch for whitelisted (#172)
This commit is contained in:
parent
c172bfe142
commit
2c170c3c2d
1 changed files with 19 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import {
|
|||
GetSqueakProfileRequest,
|
||||
SetSqueakProfileFollowingRequest,
|
||||
SetSqueakProfileSharingRequest,
|
||||
SetSqueakProfileWhitelistedRequest,
|
||||
} from "../../proto/squeak_admin_pb"
|
||||
import { SqueakAdminClient } from "../../proto/squeak_admin_grpc_web_pb"
|
||||
|
||||
|
|
@ -68,6 +69,17 @@ export default function ProfilePage() {
|
|||
getSqueakProfile(id);
|
||||
});
|
||||
};
|
||||
const setWhitelisted = (id, whitelisted) => {
|
||||
console.log("called setWhitelisted with profileId: " + id + ", whitelisted: " + whitelisted);
|
||||
var setSqueakProfileWhitelistedRequest = new SetSqueakProfileWhitelistedRequest()
|
||||
setSqueakProfileWhitelistedRequest.setProfileId(id);
|
||||
setSqueakProfileWhitelistedRequest.setWhitelisted(whitelisted);
|
||||
console.log(setSqueakProfileWhitelistedRequest);
|
||||
client.setSqueakProfileWhitelisted(setSqueakProfileWhitelistedRequest, {}, (err, response) => {
|
||||
console.log(response);
|
||||
getSqueakProfile(id);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
|
|
@ -86,6 +98,12 @@ export default function ProfilePage() {
|
|||
setSharing(id, event.target.checked);
|
||||
};
|
||||
|
||||
const handleSettingsWhitelistedChange = (event) => {
|
||||
console.log("Whitelisted changed for profile id: " + id);
|
||||
console.log("Whitelisted changed to: " + event.target.checked);
|
||||
setWhitelisted(id, event.target.checked);
|
||||
};
|
||||
|
||||
const handleSettingsChange = (event) => {
|
||||
console.log("Settings changed...");
|
||||
setState({ ...state, [event.target.name]: event.target.checked });
|
||||
|
|
@ -124,7 +142,7 @@ export default function ProfilePage() {
|
|||
label="Sharing"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={<Switch checked={squeakProfile.getWhitelisted()} onChange={handleSettingsChange} />}
|
||||
control={<Switch checked={squeakProfile.getWhitelisted()} onChange={handleSettingsWhitelistedChange} />}
|
||||
label="Whitelisted"
|
||||
/>
|
||||
</FormGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue