Skip to content

Instantly share code, notes, and snippets.

@bengotow

bengotow/main.js

Created Jul 10, 2019
Embed
What would you like to do?
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