File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 11import "./App.css" ;
22import logo from "./assets/wordmark-white-text.svg" ;
33
4+ import { useEffect } from "react" ;
45import { FormattedMessage } from "react-intl" ;
56
67import { ShareSheet } from "./ShareSheet" ;
@@ -17,14 +18,31 @@ const Logo = () => (
1718) ;
1819
1920function App ( ) {
20- const hasText = useTextParam ( ) !== null ;
21+ const text = useTextParam ( ) ;
22+
23+ useEffect ( ( ) => {
24+ let frame ;
25+
26+ if ( text !== null && "ontouchstart" in document . documentElement ) {
27+ frame = document . createElement ( "iframe" ) ;
28+ frame . style . position = "fixed" ;
29+ frame . src = `mastodon://share?text=${ encodeURIComponent ( text ) } ` ;
30+ document . body . appendChild ( frame ) ;
31+ }
32+
33+ return ( ) => {
34+ if ( frame ) {
35+ document . body . removeChild ( frame ) ;
36+ }
37+ } ;
38+ } , [ text ] ) ;
2139
2240 return (
2341 < div className = "w-full sm:max-w-lg py-12 sm:py-20 sm:m-auto flex flex-col items-center" >
2442 < Logo />
2543
2644 < div className = "p-8 sm:min-w-lg rounded-2xl sm:bg-white" >
27- { hasText ? < ShareSheet /> : < Instructions /> }
45+ { text !== null ? < ShareSheet /> : < Instructions /> }
2846 </ div >
2947
3048 < div className = "mt-12 sm:mt-30 text-slate-500 text-sm" >
You can’t perform that action at this time.
0 commit comments