@@ -66,6 +66,44 @@ const getNatOptions = (username = undefined) =>
6666 ]
6767 ) ;
6868
69+
70+ const asd = ( props , prevProps ) => {
71+ if ( isUserOwner ( this . props ) && this . props . project . id ) {
72+ if (
73+ props . preferences . autosave &&
74+ props . ide . unsavedChanges &&
75+ ! props . ide . justOpenedProject
76+ ) {
77+ if (
78+ props . selectedFile . name === prevProps . selectedFile . name &&
79+ props . selectedFile . content !== prevProps . selectedFile . content
80+ ) {
81+ if ( this . autosaveInterval ) {
82+ clearTimeout ( this . autosaveInterval ) ;
83+ }
84+ console . log ( 'will save project in 20 seconds' ) ;
85+ this . autosaveInterval = setTimeout ( props . autosaveProject , 20000 ) ;
86+ }
87+ } else if ( this . autosaveInterval && ! props . preferences . autosave ) {
88+ clearTimeout ( this . autosaveInterval ) ;
89+ this . autosaveInterval = null ;
90+ }
91+ } else if ( this . autosaveInterval ) {
92+ clearTimeout ( this . autosaveInterval ) ;
93+ this . autosaveInterval = null ;
94+ }
95+ } ;
96+
97+ const useEffectWithComparison = ( fn , props ) => {
98+ const [ prevProps , update ] = useState ( { } ) ;
99+
100+ return useEffect ( ( ) => {
101+ fn ( props , prevProps ) ;
102+ update ( props ) ;
103+ } , Object . values ( props ) ) ;
104+ } ;
105+
106+
69107const MobileIDEView = ( props ) => {
70108 const {
71109 ide, project, selectedFile, user, params, unsavedChanges, collapseConsole,
@@ -103,6 +141,9 @@ const MobileIDEView = (props) => {
103141 } , [ params , project , username ] ) ;
104142
105143
144+ // useEffectWithComparison(() => alert('haha'), { consoleIsExpanded });
145+
146+
106147 return (
107148 < Screen fullscreen >
108149 < Header
0 commit comments