react-chrome-extension-boilerplate icon indicating copy to clipboard operation
react-chrome-extension-boilerplate copied to clipboard

To modify file the badge.js

Open jeenhyung opened this issue 6 years ago • 0 comments

Original source code: LINK

chrome.storage.local.get('todos', (obj) => {
  let todos = obj.todos;
  if (todos) {
    todos = JSON.parse(todos);
    const len = todos.filter(todo => !todo.marked).length;
    if (len > 0) {
      chrome.browserAction.setBadgeText({ text: len.toString() });
    }
  } else {
    // Initial
    chrome.browserAction.setBadgeText({ text: '1' });
  }
});

to

chrome.storage.local.get('state', (obj) => { 
  const state = JSON.parse(obj.state);
  const todos = state.todos;
  if (todos) {
    const len = todos.filter(todo => !todo.marked).length;
    if (len > 0) {
      chrome.browserAction.setBadgeText({ text: len.toString() });
    }
  } else {
    // Initial
    chrome.browserAction.setBadgeText({ text: '1' });
  }
});

jeenhyung avatar Mar 20 '20 17:03 jeenhyung