diff options
author | 2022-09-12 13:14:29 +0200 | |
---|---|---|
committer | 2022-09-12 13:14:29 +0200 | |
commit | b42469e4e06d82a0e458b94379e226257ba3ca6c (patch) | |
tree | f4df0740ff0378dd4d3691cac4e942ea0a22eb5a /web/source/panels/user/index.js | |
parent | [feature] Fetch + display custom emoji in statuses from remote instances (#807) (diff) | |
download | gotosocial-b42469e4e06d82a0e458b94379e226257ba3ca6c.tar.xz |
[feature] Allow users to set custom css for their profiles + threads (#808)
* add custom css account property + db func to fetch
* allow account to get/set custom css
* serve custom css for an account
* go fmt
* use monospace for customcss, add link
* add custom css to account cache
* fix broken field
* add custom css docs to user guide
* add `accounts-allow-custom-css` config flag
* add allow custom css to /api/v1/instance response
* only show/set custom css if allowed to do so
* only set/serve custom account css if enabled
* update swagger docs
* chain promise
* make bool a bit clearer
* use cache for GetAccountCustomCSSByUsername
Diffstat (limited to 'web/source/panels/user/index.js')
-rw-r--r-- | web/source/panels/user/index.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/web/source/panels/user/index.js b/web/source/panels/user/index.js index bb8b263d6..aeecac415 100644 --- a/web/source/panels/user/index.js +++ b/web/source/panels/user/index.js @@ -33,26 +33,40 @@ require("./style.css"); function UserPanel({oauth}) { const [account, setAccount] = React.useState({}); + const [allowCustomCSS, setAllowCustomCSS] = React.useState(false); const [errorMsg, setError] = React.useState(""); const [statusMsg, setStatus] = React.useState("Fetching user info"); React.useEffect(() => { + + }, [oauth, setAllowCustomCSS, setError, setStatus]); + + React.useEffect(() => { Promise.try(() => { - return oauth.apiRequest("/api/v1/accounts/verify_credentials", "GET"); + return oauth.apiRequest("/api/v1/instance", "GET"); }).then((json) => { - setAccount(json); + setAllowCustomCSS(json.configuration.accounts.allow_custom_css); + Promise.try(() => { + return oauth.apiRequest("/api/v1/accounts/verify_credentials", "GET"); + }).then((json) => { + setAccount(json); + }).catch((e) => { + setError(e.message); + setStatus(""); + }); }).catch((e) => { setError(e.message); setStatus(""); }); - }, [oauth, setAccount, setError, setStatus]); + + }, [oauth, setAllowCustomCSS, setAccount, setError, setStatus]); return ( <React.Fragment> <div> <button className="logout" onClick={oauth.logout}>Log out of settings panel</button> </div> - <Basic oauth={oauth} account={account}/> + <Basic oauth={oauth} account={account} allowCustomCSS={allowCustomCSS}/> <Posts oauth={oauth} account={account}/> <Security oauth={oauth}/> </React.Fragment> |