Skip to content

Instantly share code, notes, and snippets.

@bengotow
Created July 10, 2019 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bengotow/d5a0357e41f7b884089bc08ce8a89547 to your computer and use it in GitHub Desktop.
Save bengotow/d5a0357e41f7b884089bc08ce8a89547 to your computer and use it in GitHub Desktop.
Mailspring plugin to assign a class to each thread list row
// keep in mind this is a plain JavaScript file - the app won't "transpile" it
// in any way (Mailspring used to run Babel when it read plugin source code,
// but it became difficult to package up Babel as part of the application).
// We can still use most ES2016 language features because we use the latest Chrome.
// When you add this file to your theme also be sure to add a `main` entry to the
// package.json file to tell it that it should load this as the entrypoint of your plugin:
//
// {
// "main": "./main",
// ...
// }
const { ExtensionRegistry, AccountStore } = require('mailspring-exports');
const ThemeThreadListExtension = {
name: 'ThemeThreadListExtension',
cssClassNamesForThreadListItem(thread) {
const allAccountIds = AccountStore.accountIds();
return `account-${allAccountIds.indexOf(thread.accountId)}`;
},
cssClassNamesForThreadListIcon(thread) {
return '';
},
};
module.exports = {
activate() {
ExtensionRegistry.ThreadList.register(ThemeThreadListExtension);
},
deactivate() {
ExtensionRegistry.ThreadList.unregister(ThemeThreadListExtension);
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment