Commit dc26b19a authored by Eric Gregory's avatar Eric Gregory

Closes #7120 Store and update unseen count in database

parent 34236be3
......@@ -9,3 +9,4 @@ install(FILES version-006.sql DESTINATION ${SQL_DEST})
install(FILES version-007.sql DESTINATION ${SQL_DEST})
install(FILES version-008.sql DESTINATION ${SQL_DEST})
install(FILES version-009.sql DESTINATION ${SQL_DEST})
install(FILES version-010.sql DESTINATION ${SQL_DEST})
--
-- Add unread count column to the FolderTable
--
ALTER TABLE FolderTable ADD COLUMN unread_count INTEGER DEFAULT 0;
......@@ -107,7 +107,7 @@ private class Geary.ImapDB.Account : BaseObject {
// create the folder object
Db.Statement stmt = cx.prepare(
"INSERT INTO FolderTable (name, parent_id, last_seen_total, last_seen_status_total, "
+ "uid_validity, uid_next, attributes) VALUES (?, ?, ?, ?, ?, ?, ?)");
+ "uid_validity, uid_next, attributes, unread_count) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
stmt.bind_string(0, path.basename);
stmt.bind_rowid(1, parent_id);
stmt.bind_int(2, Numeric.int_floor(properties.select_examine_messages, 0));
......@@ -117,6 +117,7 @@ private class Geary.ImapDB.Account : BaseObject {
stmt.bind_int64(5, (properties.uid_next != null) ? properties.uid_next.value
: Imap.UID.INVALID);
stmt.bind_string(6, properties.attrs.serialize());
stmt.bind_int(7, properties.email_unread);
stmt.exec(cancellable);
......@@ -146,15 +147,17 @@ private class Geary.ImapDB.Account : BaseObject {
Db.Statement stmt;
if (parent_id != Db.INVALID_ROWID) {
stmt = cx.prepare(
"UPDATE FolderTable SET attributes=? WHERE parent_id=? AND name=?");
"UPDATE FolderTable SET attributes=?, unread_count=? WHERE parent_id=? AND name=?");
stmt.bind_string(0, properties.attrs.serialize());
stmt.bind_rowid(1, parent_id);
stmt.bind_string(2, path.basename);
stmt.bind_int(1, properties.email_unread);
stmt.bind_rowid(2, parent_id);
stmt.bind_string(3, path.basename);
} else {
stmt = cx.prepare(
"UPDATE FolderTable SET attributes=? WHERE parent_id IS NULL AND name=?");
"UPDATE FolderTable SET attributes=?, unread_count=? WHERE parent_id IS NULL AND name=?");
stmt.bind_string(0, properties.attrs.serialize());
stmt.bind_string(1, path.basename);
stmt.bind_int(1, properties.email_unread);
stmt.bind_string(2, path.basename);
}
stmt.exec();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment