diff options
author | bnewbold <bnewbold@robocracy.org> | 2024-02-12 15:22:03 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-12 15:22:03 -0800 |
commit | d7a3246fe3bd95adfcc43762e0276b375dce026a (patch) | |
tree | f2825b5ee3298e08cd7851f29ffd4297d2d40857 /src/lib/api/debug-appview-proxy-header.ts | |
parent | b308d7e65d6956f241d865e1e79e803e0525c533 (diff) | |
download | voidsky-d7a3246fe3bd95adfcc43762e0276b375dce026a.tar.zst |
basic export repository link in settings (#2641)
* basic export repository link in settings Absolutely no prior React experience, and limited TypeScript, so probably doing all kinds of things wrong! I tried to make it a download button instead of link but that didn't work. There is probably a safer way to construct the URL string. I think having the download open in the browser is reasonable, as opposed to an in-app save flow in mobile. But i'm not sure. * Remove appview proxy toggle * Move Settings screen to a subfolder * Add support for the download attribute on links in web * Rewrite ExportRepository modal using ALF * Mobile ui tweaks --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/lib/api/debug-appview-proxy-header.ts')
-rw-r--r-- | src/lib/api/debug-appview-proxy-header.ts | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/lib/api/debug-appview-proxy-header.ts b/src/lib/api/debug-appview-proxy-header.ts deleted file mode 100644 index 44363cde2..000000000 --- a/src/lib/api/debug-appview-proxy-header.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * APP-700 - * - * This is a temporary debug setting we're running on the Web build to - * help the protocol team test some changes. - * - * It should be removed in ~2 weeks. It should only be used on the Web - * version of the app. - */ - -import {useState, useCallback, useEffect} from 'react' -import {BskyAgent} from '@atproto/api' -import * as Storage from 'lib/storage' - -export function useDebugHeaderSetting(agent: BskyAgent): [boolean, () => void] { - const [enabled, setEnabled] = useState<boolean>(false) - - useEffect(() => { - async function check() { - if (await isEnabled()) { - setEnabled(true) - } - } - check() - }, []) - - const toggle = useCallback(() => { - if (!enabled) { - Storage.saveString('set-header-x-appview-proxy', 'yes') - agent.api.xrpc.setHeader('x-appview-proxy', 'true') - setEnabled(true) - } else { - Storage.remove('set-header-x-appview-proxy') - agent.api.xrpc.unsetHeader('x-appview-proxy') - setEnabled(false) - } - }, [setEnabled, enabled, agent]) - - return [enabled, toggle] -} - -export function setDebugHeader(agent: BskyAgent, enabled: boolean) { - if (enabled) { - Storage.saveString('set-header-x-appview-proxy', 'yes') - agent.api.xrpc.setHeader('x-appview-proxy', 'true') - } else { - Storage.remove('set-header-x-appview-proxy') - agent.api.xrpc.unsetHeader('x-appview-proxy') - } -} - -export async function applyDebugHeader(agent: BskyAgent) { - if (await isEnabled()) { - agent.api.xrpc.setHeader('x-appview-proxy', 'true') - } -} - -async function isEnabled() { - return (await Storage.loadString('set-header-x-appview-proxy')) === 'yes' -} |