@ -18,7 +18,13 @@ type Props = {
/ * *
* Used for translation .
* /
t : Function
t : Function ,
/ * *
* Used to determine if invitation link should be automatically copied
* after creating a meeting .
* /
_enableAutomaticUrlCopy : boolean ,
} ;
type State = {
@ -58,6 +64,7 @@ class CopyMeetingUrl extends Component<Props, State> {
this . _hideLinkCopied = this . _hideLinkCopied . bind ( this ) ;
this . _showCopyLink = this . _showCopyLink . bind ( this ) ;
this . _showLinkCopied = this . _showLinkCopied . bind ( this ) ;
this . _copyUrlAutomatically = this . _copyUrlAutomatically . bind ( this ) ;
}
_copyUrl : ( ) => void ;
@ -135,6 +142,37 @@ class CopyMeetingUrl extends Component<Props, State> {
} ) ;
}
_copyUrlAutomatically : ( ) => void ;
/ * *
* Attempts to automatically copy invitation URL .
* Document has to be focused in order for this to work .
*
* @ private
* @ returns { void }
* /
_copyUrlAutomatically ( ) {
navigator . clipboard . writeText ( this . props . url )
. then ( ( ) => {
this . _showLinkCopied ( ) ;
window . setTimeout ( this . _hideLinkCopied , COPY _TIMEOUT ) ;
} ) ;
}
/ * *
* Implements React ' s { @ link Component # componentDidMount ( ) } . Invoked
* immediately before mounting occurs .
*
* @ inheritdoc
* /
componentDidMount ( ) {
const { _enableAutomaticUrlCopy } = this . props ;
if ( _enableAutomaticUrlCopy ) {
setTimeout ( this . _copyUrlAutomatically , 2000 ) ;
}
}
/ * *
* Implements React ' s { @ link Component # render ( ) } .
*
@ -177,8 +215,11 @@ class CopyMeetingUrl extends Component<Props, State> {
* @ returns { Object }
* /
function mapStateToProps ( state ) {
const { enableAutomaticUrlCopy } = state [ 'features/base/config' ] ;
return {
url : getCurrentConferenceUrl ( state )
url : getCurrentConferenceUrl ( state ) ,
_enableAutomaticUrlCopy : enableAutomaticUrlCopy || false
} ;
}