-
Notifications
You must be signed in to change notification settings - Fork 0
Unofficial Mailspring API Docs
Mailspring's APIs are exported from mailspring-exports
.
See https://foundry376.github.io/Mailspring/classes/ComponentRegistry.html.
import { DatabaseStore } from 'mailspring-exports';
You can listen to changes in Mailspring's database.
unlisten = DatabaseStore.listen(this._onDataChanged, this);
unlisten()
can be called to unsubscribe from the store.
When there is a change, the subscriber is called with an object referred to as the payload with the following properties.
{ objectClass: string, objects: object[] }
-
objectClass
: the type of object that changed, e.g. 'Thread' -
objects
: a collection of the objects that changed, with their current (new) properties
See also: https://foundry376.github.io/Mailspring/classes/DatabaseStore.html.
See https://foundry376.github.io/Mailspring/classes/WorkspaceStore.html.
This store represents the components that are shown in each tab in the preferences view.
import { PreferencesUIStore } from 'mailspring-exports';
You can use the PreferencesUIStore.TabItem
constructor to create an object
representing a preferences tab.
preferencesTab = new PreferencesUIStore.TabItem({
tabId: 'Todoer',
displayName: 'Todoer',
componentClassFn: () => settingsService.injectInto(Settings, React)
});
The constructor takes an object with the following properties:
{
tabId: string,
displayName: string,
componentClassFn: () => subclass of React.Component
}
-
tabId
: an identifier for the tab item, presumably must be unique -
displayName
: the name of the tab item that is shown in the UI -
componentClassFn
: a function that returns the React component class that will be used for the tab's content; maybe the function can return a functional component
PreferencesUIStore.registerPreferencesTab
takes a TabItem
and adds it to the
preferences view so that users can actually see and interact with it.
PreferencesUIStore.registerPreferencesTab(preferencesTab);
PreferencesUIStore.unregisterPreferencesTab
takes a tab's section ID, which
you can find at the sectionId
property of TabItem
objects, and removes the
corresponding tab from the preferences view.
PreferencesUIStore.unregisterPreferencesTab(preferencesTab.sectionId);
In Mailspring plugins, you import React from mailspring-exports
.
import { React } from 'mailspring-exports';
Suggested reading: the React docs