mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 01:16:30 +00:00
Merge "CollabTarget: remember current name, briefly"
This commit is contained in:
commit
a8ca28da84
|
@ -111,7 +111,7 @@ ve.init.mw.CollabTarget.prototype.attachToolbar = function () {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ve.init.mw.CollabTarget.prototype.setSurface = function ( surface ) {
|
ve.init.mw.CollabTarget.prototype.setSurface = function ( surface ) {
|
||||||
var synchronizer, surfaceView;
|
var synchronizer, surfaceView, defaultName;
|
||||||
|
|
||||||
if ( surface !== this.surface ) {
|
if ( surface !== this.surface ) {
|
||||||
this.$editableContent.after( surface.$element );
|
this.$editableContent.after( surface.$element );
|
||||||
|
@ -123,12 +123,22 @@ ve.init.mw.CollabTarget.prototype.setSurface = function ( surface ) {
|
||||||
this.title.toString(),
|
this.title.toString(),
|
||||||
{ server: this.rebaserUrl }
|
{ server: this.rebaserUrl }
|
||||||
);
|
);
|
||||||
|
synchronizer.on( 'authorNameChange', function ( authorId ) {
|
||||||
|
var newName = synchronizer.authorNames[ authorId ];
|
||||||
|
if ( authorId === synchronizer.getAuthorId() ) {
|
||||||
|
mw.storage.session.set( 've-collab-username', newName );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
// TODO: server could communicate with MW (via oauth?) to know the
|
// TODO: server could communicate with MW (via oauth?) to know the
|
||||||
// current-user's name. Disable changing name if logged in?
|
// current-user's name. Disable changing name if logged in?
|
||||||
// Communicate an I-am-a-valid-user flag to other clients?
|
// Communicate an I-am-a-valid-user flag to other clients?
|
||||||
if ( !mw.user.isAnon() ) {
|
defaultName = mw.storage.session.get( 've-collab-username' );
|
||||||
synchronizer.changeName( mw.user.getName() );
|
if ( !defaultName && !mw.user.isAnon() ) {
|
||||||
|
defaultName = mw.user.getName();
|
||||||
|
}
|
||||||
|
if ( defaultName ) {
|
||||||
|
synchronizer.changeName( defaultName );
|
||||||
}
|
}
|
||||||
|
|
||||||
surfaceView.setSynchronizer( synchronizer );
|
surfaceView.setSynchronizer( synchronizer );
|
||||||
|
|
Loading…
Reference in a new issue