💌 A beautiful, fast and fully open source mail client for Mac, Windows and Linux.
Find a file
Ben Gotow b2f8b34a32 feat(counts): Unread counts for all folders and labels across all accounts
Summary:
This diff replaces the UnreadCountStore with a better approach that is able to track unread counts for all folders/labels without continuous (and cripplingly slow) SELECT COUNT(*) queries.

When models are written to the database, we currently don't send out notifications with the "previous" state of those objects in the database. This makes it hard to determine how to update counters. (In the future, we may need to do this for live queries). Unfortunately, getting the "previous" state is going to be very hard, because multiple windows write to the database and the "previous" state we have might be outdated. We'd almost have to run a "SELECT" right before every "REPLACE INTO".

I created an API that allows you to register observers around persistModel and unpersistModel. With this API, you can run queries before and after the database changes are made and pluck just the "before" state you're interested in.

The `ThreadCountsStore` uses this API to determine the impact of persisting a set of threads on the unread counts of different labels. Before the threads are saved, it says "how much do these thread IDs contribute to unread counts currently?". After the write is complete it looks at the models and computes the difference between the old count impact and the new count impact, and updates the counters.

I decided not to attach the unread count to the Label objects themselves because 1) they update frequently and 2) most things observing the DatabaseStore for categories do not care about counts, so they would be updating unnecessarily.

The AccountSidebar now listens to the ThreadCountsStore as well as the CategoryStore, and there's a new preference in the General tab for turning off the counts.

Test Plan: Tests are a work in progress, want to get feedback first!

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2232
2015-11-23 17:12:22 -08:00
apm refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
build fix(spec): cleanup N1.sh and make specs fail with exit code 1 2015-11-23 16:00:55 -05:00
docs refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
dot-nylas feat(keymap): add new <KeymapHandlers /> 2015-11-06 11:47:06 -08:00
examples fix(examples): Small fixes for Send Availability plugin 2015-11-20 15:21:58 -08:00
internal_packages feat(counts): Unread counts for all folders and labels across all accounts 2015-11-23 17:12:22 -08:00
keymaps fix(keymaps): Small tweaks to fix broken key behaviors 2015-11-13 16:05:40 -08:00
menus fix(menu): Allow fast-switch between accounts 2015-11-06 18:19:49 -08:00
script fix(build): bail if script/bootstrap fails and enhance test output 2015-11-23 14:34:18 -05:00
spec feat(counts): Unread counts for all folders and labels across all accounts 2015-11-23 17:12:22 -08:00
spectron fix(spectron): Update window count spec 2015-11-19 14:42:34 -08:00
src feat(counts): Unread counts for all folders and labels across all accounts 2015-11-23 17:12:22 -08:00
static fix(prefs): Move to a sheet rather than a window, use configSchema 2015-11-23 12:20:51 -08:00
.eslintrc Update grunt tasks to lint and transpile es6 code using babel 2015-11-06 17:40:42 -08:00
.gitignore 🍒(atom): Pull new, cleaner compile cache + index.js 2015-11-17 19:43:08 -08:00
.travis.yml fix(travis): disable node 4 for now 2015-10-07 22:52:20 -04:00
CHANGELOG.md changelog(0.3.23): Features, fixes in 0.3.23 2015-11-17 10:37:58 -08:00
CONTRIBUTING.md Update CONTRIBUTING.md 2015-10-29 16:58:46 -07:00
LICENSE.md meta(license): Add GPLv3 License 2015-10-01 10:23:42 -07:00
N1.sh fix(spec): cleanup N1.sh and make specs fail with exit code 1 2015-11-23 16:00:55 -05:00
package.json fix(packages): remove vm-compatibility-layer 2015-11-21 00:17:27 -05:00
README.md fix(sp): It's => its 2015-10-29 19:35:31 -07:00

N1 Logo

N1 Screenshot

N1 is an open-source mail client built on the modern web with Electron, React, and Flux. It is designed to be extensible, so it's easy to create new experiences and workflows around email. N1 is built on the Nylas Sync Engine which is also open source free software.

Build Status Slack Invite Button

Download N1

You can download compiled versions of N1 for Windows, Mac OS X, and Linux (.deb) from https://nylas.com/N1. You can also build and run N1 on Fedora. A Fedora distribution is coming soon!

Build A Plugin

Plugins lie at the heart of N1 and give it its powerful features. Building your own plugins allows you to integrate the app with other tools, experiment with new workflows, and more. Follow the Getting Started guide to write your first plugin in 5 minutes.

If you would like to run the N1 source and contribute, check out our contributing guide

Running Locally

By default the N1 source points to our hosted version of the Nylas Sync Engine; however, the Sync Engine is open source and you can run it yourself.

Feature Requests / Package Ideas

Have an idea for a package, or a feature you'd love to see in N1? Check out our public Trello board to contribute your thoughts and vote on existing ideas.