import { check } from 'meteor/check';

Meteor.publish("users", function() {
    // if (!this.userId) {
    //     return this.ready();
    // }
    // return Clients.find({});

    if (this.userId) {
        let isMarcoAdmin = Meteor.users.findOne({ _id: this.userId });
        if (isMarcoAdmin.username == "marcoadmin") {
            return Meteor.users.find({ username: { $ne: "marcoadmin" } }, {

                disableOplog: true,
                // pollingThrottleMs: 1000,
                pollingIntervalMs: 1000
            });
        }

        // return Meteor.users.find({});
        else
            return Meteor.users.find({ _id: this.userId }, {

                disableOplog: true,
                // pollingThrottleMs: 1000,
                pollingIntervalMs: 1000
            });
        // return Clients.find({}, {

        //     reactive: true,
        //     disableOplog: false,
        //     pollingThrottleMs: 1000,
        //     pollingIntervalMs: 1000
        // })


    } else {
        return [];
    }

});