@@ -69,11 +69,21 @@ var MongoDBCollectionView = View.extend({
69
69
initialize : function ( ) {
70
70
this . model = new MongoDBCollection ( ) ;
71
71
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 ) ) ;
74
74
this . listenToAndRun ( this . parent , 'change:ns' , this . onCollectionChanged . bind ( this ) ) ;
75
75
} ,
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 ( ) {
77
87
var clipboard = window . require ( 'clipboard' ) ;
78
88
clipboard . writeText ( JSON . stringify ( this . schema . serialize ( ) , null , ' ' ) ) ;
79
89
$ ( this . queryByHook ( 'share-schema-confirmation' ) ) . modal ( 'show' ) ;
0 commit comments