Implement asynchronous history
This MR rewrites
chatty-history and moves all database actions to separated thread to avoid UI freeze. But since some code requires synchronous handling of the database, some API similar to the existing APIs has been added. Though they are synchronous, they won't freeze UI.
This MR depends on !386 (closed)