mgsloan / todoist-shortcuts

Browser extension which adds comprehensive keyboard shortcuts to Todoist, beyond what is offered by Todoist itself
MIT License
313 stars 23 forks source link

navigateToLeftMenuItem #239

Open mdbraber opened 1 year ago

mdbraber commented 1 year ago

I wanted a function that could navigate directly to a specific top section, favorite or project - see the code below. I've used the updated withLeftMenuItems from https://github.com/mgsloan/todoist-shortcuts/issues/232. The itemId can be today, upcoming or any itemId that Todoist creates for projects or filters. This way you can easily navigate to projects with the same name (and code doesn't have to be updated if projects get renamed).

  function navigateToLeftMenuItem(itemId) {
      return () => {
          withLeftMenuItems(['top','favorites','projects'], (menuItems, current) => {
              for (const menuItem of menuItems) {
                  if(menuItem.href.indexOf(itemId) > 0) {
                      click(menuItem);
                  }
              }
          });
      }
  }

You can make keybinding as follows:

    ['command+1', navigateToLeftMenuItem('377156504')],
    ['command+2', navigateToLeftMenuItem('today')],
    ['command+3', navigateToLeftMenuItem('upcoming')],
mgsloan commented 1 year ago

Cool, thanks! I've added this code to version 173

mdbraber commented 1 year ago

Thanks @mgsloan - I think we also then need the updated code from #232 which also fixes the navigation issues mentioned there (issue is closed officially - maybe reopen if it needs work?)

mgsloan commented 1 year ago

Welcome! Yeah, was going to try to include that in this release but didn't get around to it. Will write more on that issue

mdbraber commented 1 year ago

No problem. Just mentioning that the withLeftMenuLinks code is from my updated function so not from < v173. So if that code fron #232 is not integrated in v173 it might need some (temporary updating). Check the sections part of the code.

mgsloan commented 1 year ago

Ohh, I see! Yeah that should be fixed, reopening this

On Tue, Jan 24, 2023 at 12:04 AM Maarten den Braber < @.***> wrote:

No problem. Just mentioning that the withLeftMenuLinks code is from my updated function so not from < v173. So if that code is not integrated in v173 it might need some (temporary updating). Check the sections part of the code.

— Reply to this email directly, view it on GitHub https://github.com/mgsloan/todoist-shortcuts/issues/239#issuecomment-1401474165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFQKVPE4M6K7NWZ5WOLILWT55I5ANCNFSM6AAAAAAUALNAVA . You are receiving this because you were mentioned.Message ID: @.***>