For most users, I want to hide the pose picker if there's not actually anything to pick from. But I want Support users to be able to open it and use Support mode, to inspect and label Unknown poses! In this change, I add new UI to show a question mark pose picker button, and a note explaining the empty picker; but only show them for Support users. I also made a new `useSupport` hook, to replace `useSupportSecret`, now that I have a use case for "is support user?" that doesn't require the secret. Will migrate the rest!
29 lines
939 B
JavaScript
29 lines
939 B
JavaScript
import * as React from "react";
|
|
|
|
/**
|
|
* useSupport returns the Support secret that the server requires for Support
|
|
* actions... if the user has it set. For most users, this returns nothing!
|
|
*
|
|
* Specifically, we return an object of:
|
|
* - isSupportUser: true iff the `supportSecret` is set
|
|
* - supportSecret: the secret saved to this device, or null if not set
|
|
*
|
|
* To become a Support user, you visit /?supportSecret=..., which saves the
|
|
* secret to your device.
|
|
*
|
|
* Note that this hook doesn't check that the secret is *correct*, so it's
|
|
* possible that it will return an invalid secret. That's okay, because
|
|
* the server checks the provided secret for each Support request.
|
|
*/
|
|
function useSupport() {
|
|
const supportSecret = React.useMemo(
|
|
() => localStorage.getItem("supportSecret"),
|
|
[]
|
|
);
|
|
|
|
const isSupportUser = supportSecret != null;
|
|
|
|
return { isSupportUser, supportSecret };
|
|
}
|
|
|
|
export default useSupport;
|