+ /**
+ * Update sticky preferences with current model state
+ */
+ mw.rcfilters.Controller.prototype.updateStickyPreferences = function () {
+ // Update default sticky values with selected, whether they came from
+ // the initial defaults or from the URL value that is being normalized
+ this.updateDaysDefault( this.filtersModel.getGroup( 'days' ).getSelectedItems()[ 0 ].getParamName() );
+ this.updateLimitDefault( this.filtersModel.getGroup( 'limit' ).getSelectedItems()[ 0 ].getParamName() );
+ };
+
+ /**
+ * Update the limit default value
+ *
+ * @param {number} newValue New value
+ */
+ mw.rcfilters.Controller.prototype.updateLimitDefault = function ( newValue ) {
+ if ( !$.isNumeric( newValue ) ) {
+ return;
+ }
+
+ newValue = Number( newValue );
+
+ if ( mw.user.options.get( 'rcfilters-rclimit' ) !== newValue ) {
+ // Save the preference
+ new mw.Api().saveOption( 'rcfilters-rclimit', newValue );
+ // Update the preference for this session
+ mw.user.options.set( 'rcfilters-rclimit', newValue );
+ }
+ };
+
+ /**
+ * Update the days default value
+ *
+ * @param {number} newValue New value
+ */
+ mw.rcfilters.Controller.prototype.updateDaysDefault = function ( newValue ) {
+ if ( !$.isNumeric( newValue ) ) {
+ return;
+ }
+
+ newValue = Number( newValue );
+
+ if ( mw.user.options.get( 'rcdays' ) !== newValue ) {
+ // Save the preference
+ new mw.Api().saveOption( 'rcdays', newValue );
+ // Update the preference for this session
+ mw.user.options.set( 'rcdays', newValue );
+ }
+ };
+