5
5
onWillDestroy ,
6
6
onWillUpdateProps ,
7
7
status ,
8
+ toRaw ,
8
9
useEffect ,
9
10
useRef ,
10
11
useState ,
@@ -20,6 +21,7 @@ import { Editor } from "@html_editor/editor";
20
21
import { useThrottleForAnimation } from "@web/core/utils/timing" ;
21
22
import { closestScrollableY } from "@web/core/utils/scrolling" ;
22
23
import { _t } from "@web/core/l10n/translation" ;
24
+ import { effect } from "@web/core/utils/reactive" ;
23
25
24
26
const IFRAME_VALUE_SELECTOR = ".o_mass_mailing_value" ;
25
27
@@ -61,9 +63,12 @@ export class MassMailingIframe extends Component {
61
63
useSubEnv ( {
62
64
localOverlayContainerKey : uniqueId ( "mass_mailing_iframe" ) ,
63
65
} ) ;
66
+ let showFullscreen = false ;
67
+ let isMobile = false ;
64
68
this . state = useState ( {
65
- isMobile : false ,
69
+ isMobile,
66
70
ready : false ,
71
+ showFullscreen,
67
72
} ) ;
68
73
this . iframeLoaded = new Deferred ( ) ;
69
74
onMounted ( ( ) => {
@@ -94,9 +99,31 @@ export class MassMailingIframe extends Component {
94
99
} ,
95
100
( ) => [ this . state . showFullscreen ]
96
101
) ;
97
- if ( ! this . props . readonly && this . props . withBuilder ) {
98
- this . state . showFullscreen = false ;
99
- } else if ( ! this . props . readonly ) {
102
+ effect (
103
+ ( state ) => {
104
+ if ( status ( this ) === "destroyed" ) {
105
+ return ;
106
+ }
107
+ if ( showFullscreen && ! state . showFullscreen && toRaw ( state ) . isMobile ) {
108
+ state . isMobile = false ;
109
+ }
110
+ showFullscreen = state . showFullscreen ;
111
+ } ,
112
+ [ this . state ]
113
+ ) ;
114
+ effect (
115
+ ( state ) => {
116
+ if ( status ( this ) === "destroyed" ) {
117
+ return ;
118
+ }
119
+ if ( ! isMobile && state . isMobile && ! toRaw ( state ) . showFullscreen ) {
120
+ state . showFullscreen = true ;
121
+ }
122
+ isMobile = state . isMobile ;
123
+ } ,
124
+ [ this . state ]
125
+ ) ;
126
+ if ( ! this . props . readonly && ! this . props . withBuilder ) {
100
127
this . editor = new Editor ( this . props . config , this . env . services ) ;
101
128
this . props . onEditorLoad ( this . editor ) ;
102
129
onWillDestroy ( ( ) => {
0 commit comments