Add a link to Special:EditRecovery after the 'Contributions' link in the personal menu. Grey it out if there is no data to show. Bug: T351781 Change-Id: I0863f4e824cc2dc70d8a5fddea9dbfb2958fd478
28 lines
978 B
JavaScript
28 lines
978 B
JavaScript
'use strict';
|
|
|
|
mw.hook( 'postEdit' ).add( function () {
|
|
const storage = require( './storage.js' );
|
|
storage.openDatabase().then( function () {
|
|
storage.deleteData( mw.config.get( 'wgPageName' ) );
|
|
storage.closeDatabase();
|
|
} );
|
|
} );
|
|
|
|
// Hide the link to Special:EditRecovery if there's no data to recovery.
|
|
const editRecoveryLink = document.getElementById( 'pt-editrecovery' );
|
|
if ( editRecoveryLink ) {
|
|
mw.hook( 'wikipage.content' ).add( function () {
|
|
const storage = require( './storage.js' );
|
|
storage.openDatabase().then( function () {
|
|
storage.loadAllData().then( function ( data ) {
|
|
if ( data.length === 0 ) {
|
|
editRecoveryLink.classList.add( 'mw-editrecovery-no-data' );
|
|
editRecoveryLink.title = mw.msg( 'edit-recovery-link-tooltip-no-data' );
|
|
} else {
|
|
editRecoveryLink.classList.remove( 'mw-editrecovery-no-data' );
|
|
editRecoveryLink.title = mw.msg( 'edit-recovery-link-tooltip-with-data', data.length );
|
|
}
|
|
} );
|
|
} );
|
|
} );
|
|
}
|