mirror of
				https://github.com/vector-im/element-web.git
				synced 2025-11-03 17:51:51 +01:00 
			
		
		
		
	Un-inline onChange
This commit is contained in:
		
							parent
							
								
									4bfefa9396
								
							
						
					
					
						commit
						efe1c767f0
					
				@ -107,6 +107,26 @@ module.exports = React.createClass({
 | 
				
			|||||||
        UserSettingsStore.setEnableNotifications(event.target.checked);
 | 
					        UserSettingsStore.setEnableNotifications(event.target.checked);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    onEnableEmailNotificationsChange: function(address, event) {
 | 
				
			||||||
 | 
					        var emailPusherPromise;
 | 
				
			||||||
 | 
					        if (event.target.checked) {
 | 
				
			||||||
 | 
					            emailPusherPromise = UserSettingsStore.addEmailPusher(address);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
 | 
				
			||||||
 | 
					            emailPusher.kind = null;
 | 
				
			||||||
 | 
					            emailPusherPromise = MatrixClientPeg.get().setPusher(emailPusher);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        emailPusherPromise.done(() => {
 | 
				
			||||||
 | 
					            this._refreshFromServer();
 | 
				
			||||||
 | 
					        }, (error) => {
 | 
				
			||||||
 | 
					            var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
 | 
				
			||||||
 | 
					            Modal.createDialog(ErrorDialog, {
 | 
				
			||||||
 | 
					                title: "Error saving email notification preferences",
 | 
				
			||||||
 | 
					                description: "Vector was unable to save your email notification preferences.",
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    onNotifStateButtonClicked: function(event) {
 | 
					    onNotifStateButtonClicked: function(event) {
 | 
				
			||||||
        // FIXME: use .bind() rather than className metadata here surely
 | 
					        // FIXME: use .bind() rather than className metadata here surely
 | 
				
			||||||
        var vectorRuleId = event.target.className.split("-")[0];
 | 
					        var vectorRuleId = event.target.className.split("-")[0];
 | 
				
			||||||
@ -632,25 +652,8 @@ module.exports = React.createClass({
 | 
				
			|||||||
                    ref="enableEmailNotifications_{address}"
 | 
					                    ref="enableEmailNotifications_{address}"
 | 
				
			||||||
                    type="checkbox"
 | 
					                    type="checkbox"
 | 
				
			||||||
                    checked={ UserSettingsStore.hasEmailPusher(this.state.pushers, address) }
 | 
					                    checked={ UserSettingsStore.hasEmailPusher(this.state.pushers, address) }
 | 
				
			||||||
                    onChange={ (e) => {
 | 
					                    onChange={ this.onEnableEmailNotificationsChange.bind(this, address) }
 | 
				
			||||||
                        var emailPusherPromise;
 | 
					                />
 | 
				
			||||||
                        if (e.target.checked) {
 | 
					 | 
				
			||||||
                            emailPusherPromise = UserSettingsStore.addEmailPusher(address);
 | 
					 | 
				
			||||||
                        } else {
 | 
					 | 
				
			||||||
                            var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
 | 
					 | 
				
			||||||
                            emailPusher.kind = null;
 | 
					 | 
				
			||||||
                            emailPusherPromise = MatrixClientPeg.get().setPusher(emailPusher);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        emailPusherPromise.done(() => {
 | 
					 | 
				
			||||||
                            this._refreshFromServer();
 | 
					 | 
				
			||||||
                        }, (error) => {
 | 
					 | 
				
			||||||
                            var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
 | 
					 | 
				
			||||||
                            Modal.createDialog(ErrorDialog, {
 | 
					 | 
				
			||||||
                                title: "Error saving email notification preferences",
 | 
					 | 
				
			||||||
                                description: "Vector was unable to save your email notification preferences.",
 | 
					 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
                        });
 | 
					 | 
				
			||||||
                    }} />
 | 
					 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <div className="mx_UserNotifSettings_labelCell">
 | 
					            <div className="mx_UserNotifSettings_labelCell">
 | 
				
			||||||
                <label htmlFor="enableEmailNotifications_{address}">
 | 
					                <label htmlFor="enableEmailNotifications_{address}">
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user