1
- import React , { Suspense } from 'react' ;
1
+ import React , { Suspense , useEffect } from 'react' ;
2
2
import { render } from 'react-dom' ;
3
- import { Provider } from 'react-redux' ;
3
+ import { Provider , useSelector } from 'react-redux' ;
4
4
import { Router } from 'react-router-dom' ;
5
5
6
6
import { useTranslation } from 'react-i18next' ;
@@ -21,6 +21,8 @@ const initialState = window.__INITIAL_STATE__;
21
21
22
22
const store = configureStore ( initialState ) ;
23
23
24
+ const DONATE_LOGO_IMAGE_URL = 'https://donorbox.org/images/white_logo.svg' ;
25
+
24
26
if (
25
27
window . location . href . indexOf ( 'full' ) === - 1 &&
26
28
window . location . href . indexOf ( 'embed' ) === - 1
56
58
'background: #f1678e; color: #fff; text-decoration: none; font-family: Verdana, sans-serif; display: flex; gap: 8px; width: fit-content; font-size: 16px; border-radius: 0 0 5px 5px; line-height: 24px; position: fixed; top: 50%; transform-origin: center; z-index: 9999; overflow: hidden; padding: 8px 22px 8px 18px; right: 20px; left: auto; transform: translate(50%, -50%) rotate(90deg)'
57
59
) ;
58
60
buttonScript . setAttribute ( 'data-button-cta' , 'Donate' ) ;
59
- buttonScript . setAttribute (
60
- 'data-img-src' ,
61
- 'https://donorbox.org/images/white_logo.svg'
62
- ) ;
61
+ buttonScript . setAttribute ( 'data-img-src' , DONATE_LOGO_IMAGE_URL ) ;
63
62
64
63
document . body . appendChild ( buttonScript ) ;
65
64
}
66
65
67
66
const App = ( ) => {
68
67
const { t } = useTranslation ( ) ;
69
-
70
- setTimeout ( ( ) => {
71
- const donateButton = document . getElementsByClassName (
72
- 'dbox-donation-button'
73
- ) [ 0 ] ;
74
-
75
- if ( donateButton ) {
76
- const donateLogoImage = document . createElement ( 'img' ) ;
77
- donateLogoImage . src = 'https://donorbox.org/images/white_logo.svg' ;
78
-
79
- donateButton . text = t ( 'About.Donate' ) ;
80
- donateButton . prepend ( donateLogoImage ) ;
81
- }
82
- } , 0 ) ;
68
+ const language = useSelector ( ( state ) => state . preferences . language ) ;
69
+
70
+ useEffect ( ( ) => {
71
+ setTimeout ( ( ) => {
72
+ const donateButton = document . getElementsByClassName (
73
+ 'dbox-donation-button'
74
+ ) [ 0 ] ;
75
+
76
+ if ( donateButton ) {
77
+ const donateLogoImage = document . createElement ( 'img' ) ;
78
+ donateLogoImage . src = DONATE_LOGO_IMAGE_URL ;
79
+
80
+ donateButton . text = t ( 'About.Donate' ) ;
81
+ donateButton . prepend ( donateLogoImage ) ;
82
+ }
83
+ } , 500 ) ;
84
+ } , [ language ] ) ;
83
85
84
86
return (
85
87
< div >
0 commit comments