index.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React, { useEffect, useState, useCallback } from 'react'
  21. import Helmet from 'react-helmet'
  22. import { useLocation } from 'react-router-dom'
  23. import { useSelector, useDispatch } from 'react-redux'
  24. import { makeSelectTitle } from './selectors'
  25. import { ShareDisplayActions } from './actions'
  26. import { makeSelectLoginLoading } from '../App/selectors'
  27. import { useInjectReducer } from 'utils/injectReducer'
  28. import { useInjectSaga } from 'utils/injectSaga'
  29. import reducer from './reducer'
  30. import saga from './sagas'
  31. import Reveal from './Reveal'
  32. import mainStyles from 'containers/Main/Main.less'
  33. const ShareDisplayIndex: React.FC = () => {
  34. useInjectReducer({ key: 'shareDisplay', reducer })
  35. useInjectSaga({ key: 'shareDisplay', saga })
  36. const dispatch = useDispatch()
  37. const location = useLocation()
  38. const shareToken = new URLSearchParams(window.location.search).get(
  39. 'shareToken'
  40. )
  41. useEffect(() => {
  42. sessionStorage.setItem('pathname', location.pathname + location.search)
  43. }, [])
  44. const loadShareContent = useCallback(() => {
  45. dispatch(
  46. ShareDisplayActions.loadDisplay(
  47. shareToken,
  48. () => null,
  49. () => null
  50. )
  51. )
  52. }, [])
  53. useEffect(loadShareContent, [])
  54. const title = useSelector(makeSelectTitle())
  55. return (
  56. <>
  57. <Helmet title={title} />
  58. <div className={mainStyles.container}>
  59. {title && <Reveal />}
  60. </div>
  61. </>
  62. )
  63. }
  64. export default ShareDisplayIndex