define([
    'flight/lib/component',
    'data',
    'service/sync',
    './syncCursor',
    'util/withAsyncQueue'
], function (defineComponent, appData, SyncService, SyncCursor, withAsyncQueue) {
    'use strict';

    return defineComponent(Sync, withAsyncQueue);

    function Sync() {
        this.syncCursors = false; // TODO should we sync cursors? Maybe allow enabling/disabling.
        this.syncService = new SyncService();

        //PUT EVENTS YOU WANT TO SYNC HERE!
        this.events = [
            'addVertices',
            'updateVertices',
            'deleteVertices',
            'workspaceRemoteSave'
        ];

        if (this.syncCursors) {
            this.events.push('syncCursorMove');
            this.events.push('syncCursorFocus');
            this.events.push('syncCursorBlur');
        }

        this.after('initialize', function () {
            this.on(document, 'workspaceLoaded', this.onWorkspaceLoaded);
            this.on(document, 'socketMessage', this.onSocketMessage);

            this.on(document, 'onlineStatusChanged', this.onOnlineStatusChanged);
            this.on(document, 'objectsSelected', this.onObjectsSelected);

            for (var i in this.events) {
                this.on(document, this.events[i], this.onSyncedEvent);
            }
            if (this.syncCursors) {
                SyncCursor.attachTo(window);
            }

            this.setupAsyncQueue('users');
        });

        this.onWorkspaceLoaded = function(evt, workspace) {
            this.workspaceEditable = workspace.isEditable;
            this.currentWorkspaceRowKey = workspace.id;

            this.usersReady(function(usersData) {
                var user = usersData.user,
                    data = {
                        type: 'changedWorkspace',
                        permissions: {
                        },
                        data: {
                            userRowKey: user.rowKey,
                            workspaceRowKey: this.currentWorkspaceRowKey
                        }
                    };
                this.syncService.socketPush(data);
            });
        };

        this.onSocketMessage = function (evt, message) {
            message.data = message.data || {};
            message.data.eventData = message.data.eventData || {};
            switch (message.type) {
                case 'sync':
                    console.debug('sync onSocketMessage (remote: ' + (message.data.eventData.remoteEvent ? 'true' : 'false') + ')', message);
                    message.data.eventData.remoteEvent = true;
                    this.trigger(document, message.data.eventName, message.data.eventData);
                    break;
            }
        };

        this.onSyncedEvent = function (evt, data) {
            if (!this.currentWorkspaceRowKey) {
                return;
            }
            if (!this.workspaceEditable && !data.remoteEvent) {
                return;
            }
            if (data.remoteEvent) {
                return;
            }

            if (data && data.vertices) {
                data.vertices = data.vertices.map(function(vertex) {
                    return {
                        id: vertex.id,
                        workspace: vertex.workspace
                    };
                });
            }

            if (evt.type === 'workspaceRemoteSave') {
                this.syncService.publishWorkspaceMetadataSyncEvent(evt.type, this.currentWorkspaceRowKey, data);
            } else this.syncService.publishWorkspaceSyncEvent(evt.type, this.currentWorkspaceRowKey, data);
        };

        this.onOnlineStatusChanged = function (evt, data) {
            this.usersMarkReady(data);
            this.currentUser = data.user;
        };

        // This function is to support sync'ing between multiple devices with the same user
        this.onObjectsSelected = function (evt, data) {
            if (!this.currentUser) {
                return;
            }

            var vertexIds = _.pluck(data.vertices, 'id');
            this.syncService.publishUserSyncEvent(evt.type, [this.currentUser.rowKey], vertexIds);
        };
    }

});

@@ -1093,82 +1093,8 @@
 ed);
-%0A            this.on(document, 'objectsSelected', this.onObjectsSelected);
 %0A%0A  
@@ -3702,400 +3702,8 @@
 %7D;%0A%0A
-        // This function is to support sync'ing between multiple devices with the same user%0A        this.onObjectsSelected = function (evt, data) %7B%0A            if (!this.currentUser) %7B%0A                return;%0A            %7D%0A%0A            var vertexIds = _.pluck(data.vertices, 'id');%0A            this.syncService.publishUserSyncEvent(evt.type, %5Bthis.currentUser.rowKey%5D, vertexIds);%0A        %7D;%0A
     

Remove selection sync, not useful anymore