cbrooker / MMM-Todoist

This is an extension for the MagicMirror2 platform. It will display your Todoist todos on your MagicMirror.
MIT License
151 stars 58 forks source link

hideWhenEmpty not working #87

Open BoujeeBoba opened 3 years ago

BoujeeBoba commented 3 years ago

I have enabled the hideWhenEmpty parameter for this module but I can't get the header to disappear when the list is empty. The code in my config is setup as shown here:

{
        module: 'MMM-Todoist',
        position: 'top_left',   // This can be any of the regions. Best results in left or right regions.
        header: 'To Do List', // This is optional
        config: { // See 'Configuration options' for more information.
            hideWhenEmpty: true,
            accessToken: '...',
            maximumEntries: 5,
            updateInterval: 10*60*1000, // Update every 10 minutes
            fade: false,
            showProject:false,      
            //projects and/or labels is mandatory:
            projects: [ ... ] 
            //labels: [ "MagicMirror", "Important" ] // Tasks for any projects with these labels will be shown.
            }
    },

I have waited for the mirror to refresh as well as start the mirror with an empty list and the header still appears, has anyone else run into this issue?

addfozzie commented 3 years ago

Yup I have the same. End up having to leave a single item in the list. When this is used as a shopping list there can be a lot of milk bought when it isn't needed. :)

Rodriguezjp commented 3 years ago

the same problem !!!!I don't want to buy more milk !!! How could we make the header disappear? when the list is empty ...Thx!!

ckboyle commented 3 years ago

I believe there's a related issue that can come up caused by the check of this.tasks.items.length on line 564 throwing an error because that value is undefined at the time. It was causing other widgets on my page to not render.

I'd love to throw in a PR, I just don't have a dev setup for working on MM modules right now, but if I can get one together I'll try and get a PR together.

Eagle2301 commented 3 years ago

Same problem here. the check of this.tasks.items.length on line 564 causing other widgets on my page to not render. If I put false in "hideWhenEmpty" nothing is display on Todoist, but other widgets working.

schramkef commented 3 years ago

Same here. When 'hideWhenEmpty: true' it throws

TypeError: Cannot read property 'items' of undefined at Class.getDom (MMM-Todoist.js:564)

`getDom: function () {

    if (this.config.hideWhenEmpty && this.tasks.items.length===0) {
        return null;
    }`

This prevents following modules to load. Workaround is to set 'hideWhenEmpty: false'