const Parse = getApp().Parse;

function getDiyTabs(type) {
    return new Promise((reslove, reject) => {
        let query = new Parse.Query("DiyTabs");
        query.equalTo("company", getApp().globalData.company);
        query.equalTo("isOpen", true);
        type && query.equalTo('name',type)
        query.ascending('createdAt')
        query.first().then((res) => {
            console.log(res);
            let tabs = res.get("options").list;
            tabs.map((item, index) => {
                // if (!item.open) {
                //     tabs.splice(index, 1);
                // }
            });
            // getApp().globalData.defaultTabBar = res.get("options");
            let tabbarOption = res.get("options")
            reslove(tabbarOption)
        });
    })
}

module.exports = {
    getDiyTabs: getDiyTabs
}