mirror of
				https://github.com/vector-im/element-web.git
				synced 2025-11-04 02:02:14 +01:00 
			
		
		
		
	Use require so we can import conditionally
This commit is contained in:
		
							parent
							
								
									527c390152
								
							
						
					
					
						commit
						ed9c29d365
					
				@ -20,6 +20,11 @@ limitations under the License.
 | 
				
			|||||||
import VectorBasePlatform from './VectorBasePlatform';
 | 
					import VectorBasePlatform from './VectorBasePlatform';
 | 
				
			||||||
import dis from 'matrix-react-sdk/lib/dispatcher';
 | 
					import dis from 'matrix-react-sdk/lib/dispatcher';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const electron = require('electron');
 | 
				
			||||||
 | 
					const remote = electron.remote;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
 | 
					function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
 | 
				
			||||||
    dis.dispatch({
 | 
					    dis.dispatch({
 | 
				
			||||||
        action: 'new_version',
 | 
					        action: 'new_version',
 | 
				
			||||||
@ -29,14 +34,6 @@ function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// index.js imports us unconditionally, so we need this check here as well
 | 
					 | 
				
			||||||
let electron = null, remote = null;
 | 
					 | 
				
			||||||
if (window && window.process && window.process && window.process.type === 'renderer') {
 | 
					 | 
				
			||||||
    electron = require('electron');
 | 
					 | 
				
			||||||
    electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);
 | 
					 | 
				
			||||||
    remote = electron.remote;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export default class ElectronPlatform extends VectorBasePlatform {
 | 
					export default class ElectronPlatform extends VectorBasePlatform {
 | 
				
			||||||
    setNotificationCount(count: number) {
 | 
					    setNotificationCount(count: number) {
 | 
				
			||||||
        super.setNotificationCount(count);
 | 
					        super.setNotificationCount(count);
 | 
				
			||||||
 | 
				
			|||||||
@ -17,16 +17,13 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import ElectronPlatform from './ElectronPlatform';
 | 
					 | 
				
			||||||
import WebPlatform from './WebPlatform';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
let Platform = null;
 | 
					let Platform = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (window && window.process && window.process && window.process.type === 'renderer') {
 | 
					if (window && window.process && window.process && window.process.type === 'renderer') {
 | 
				
			||||||
    // we're running inside electron
 | 
					    // we're running inside electron
 | 
				
			||||||
    Platform = ElectronPlatform;
 | 
					    Platform = require('./ElectronPlatform');;
 | 
				
			||||||
} else {
 | 
					} else {
 | 
				
			||||||
    Platform = WebPlatform;
 | 
					    Platform = require('./WebPlatform');;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default Platform;
 | 
					export default Platform;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user