Created
July 10, 2019 17:19
-
-
Save bengotow/d5a0357e41f7b884089bc08ce8a89547 to your computer and use it in GitHub Desktop.
Mailspring plugin to assign a class to each thread list row
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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