@@ -69,11 +69,21 @@ var MongoDBCollectionView = View.extend({
6969 initialize : function ( ) {
7070 this . model = new MongoDBCollection ( ) ;
7171 app . statusbar . watch ( this , this . schema ) ;
72- debug ( 'app ', app ) ;
73- app . on ( 'menu-share- schema-json' , this . shareSchemaRequested . bind ( this ) ) ;
72+ this . listenTo ( this . schema , 'sync ', this . schemaIsSynced . bind ( this ) ) ;
73+ this . listenTo ( this . schema , 'request' , this . schemaIsRequested . bind ( this ) ) ;
7474 this . listenToAndRun ( this . parent , 'change:ns' , this . onCollectionChanged . bind ( this ) ) ;
7575 } ,
76- shareSchemaRequested : function ( ) {
76+ schemaIsSynced : function ( ) {
77+ // only listen to share menu events if we have a sync'ed schema
78+ // @todo enable share menu item here
79+ this . listenTo ( app , 'menu-share-schema-json' , this . onShareSchema . bind ( this ) ) ;
80+ } ,
81+ schemaIsRequested : function ( ) {
82+ // while a new schema is requested, don't let the user share via the menu option
83+ // @todo disable share menu item here
84+ this . stopListening ( app , 'menu-share-schema-json' ) ;
85+ } ,
86+ onShareSchema : function ( ) {
7787 var clipboard = window . require ( 'clipboard' ) ;
7888 clipboard . writeText ( JSON . stringify ( this . schema . serialize ( ) , null , ' ' ) ) ;
7989 $ ( this . queryByHook ( 'share-schema-confirmation' ) ) . modal ( 'show' ) ;
0 commit comments