Browse Source

Make new email relative to stored time

main
M66B 6 years ago
parent
commit
d3245ef77f
3 changed files with 13 additions and 4 deletions
  1. +9
    -3
      app/schemas/eu.faircode.email.DB/1.json
  2. +1
    -1
      app/src/main/java/eu/faircode/email/DaoAccount.java
  3. +3
    -0
      app/src/main/java/eu/faircode/email/EntityMessage.java

+ 9
- 3
app/schemas/eu.faircode.email.DB/1.json View File

@ -2,7 +2,7 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 1, "version": 1,
"identityHash": "fc698ded287d449f2781e8efa338554d",
"identityHash": "6213f410bff60ef85d8608f09052327d",
"entities": [ "entities": [
{ {
"tableName": "identity", "tableName": "identity",
@ -301,7 +301,7 @@
}, },
{ {
"tableName": "message", "tableName": "message",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `account` INTEGER, `folder` INTEGER NOT NULL, `identity` INTEGER, `replying` INTEGER, `uid` INTEGER, `msgid` TEXT, `references` TEXT, `inreplyto` TEXT, `thread` TEXT, `from` TEXT, `to` TEXT, `cc` TEXT, `bcc` TEXT, `reply` TEXT, `subject` TEXT, `body` TEXT, `sent` INTEGER, `received` INTEGER NOT NULL, `seen` INTEGER NOT NULL, `ui_seen` INTEGER NOT NULL, `ui_hide` INTEGER NOT NULL, `error` TEXT, FOREIGN KEY(`account`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`folder`) REFERENCES `folder`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`identity`) REFERENCES `identity`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replying`) REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `account` INTEGER, `folder` INTEGER NOT NULL, `identity` INTEGER, `replying` INTEGER, `uid` INTEGER, `msgid` TEXT, `references` TEXT, `inreplyto` TEXT, `thread` TEXT, `from` TEXT, `to` TEXT, `cc` TEXT, `bcc` TEXT, `reply` TEXT, `subject` TEXT, `body` TEXT, `sent` INTEGER, `received` INTEGER NOT NULL, `stored` INTEGER NOT NULL, `seen` INTEGER NOT NULL, `ui_seen` INTEGER NOT NULL, `ui_hide` INTEGER NOT NULL, `error` TEXT, FOREIGN KEY(`account`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`folder`) REFERENCES `folder`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`identity`) REFERENCES `identity`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replying`) REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -417,6 +417,12 @@
"affinity": "INTEGER", "affinity": "INTEGER",
"notNull": true "notNull": true
}, },
{
"fieldPath": "stored",
"columnName": "stored",
"affinity": "INTEGER",
"notNull": true
},
{ {
"fieldPath": "seen", "fieldPath": "seen",
"columnName": "seen", "columnName": "seen",
@ -764,7 +770,7 @@
], ],
"setupQueries": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"fc698ded287d449f2781e8efa338554d\")"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"6213f410bff60ef85d8608f09052327d\")"
] ]
} }
} }

+ 1
- 1
app/src/main/java/eu/faircode/email/DaoAccount.java View File

@ -54,7 +54,7 @@ public interface DaoAccount {
" JOIN account ON account.id = message.account" + " JOIN account ON account.id = message.account" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" WHERE NOT message.ui_seen AND NOT message.ui_hide" + " WHERE NOT message.ui_seen AND NOT message.ui_hide" +
" AND (account.seen_until IS NULL OR message.received > account.seen_until)" +
" AND (account.seen_until IS NULL OR message.stored > account.seen_until)" +
" AND folder.type = '" + EntityFolder.INBOX + "') AS unseen" + " AND folder.type = '" + EntityFolder.INBOX + "') AS unseen" +
", (SELECT COUNT(message.id) FROM message" + ", (SELECT COUNT(message.id) FROM message" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +


+ 3
- 0
app/src/main/java/eu/faircode/email/EntityMessage.java View File

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B) Copyright 2018 by Marcel Bokhorst (M66B)
*/ */
import java.util.Date;
import java.util.Random; import java.util.Random;
import javax.mail.Address; import javax.mail.Address;
@ -80,6 +81,8 @@ public class EntityMessage {
@NonNull @NonNull
public Long received; // compose = stored public Long received; // compose = stored
@NonNull @NonNull
public Long stored = new Date().getTime();
@NonNull
public Boolean seen; public Boolean seen;
@NonNull @NonNull
public Boolean ui_seen; public Boolean ui_seen;


Loading…
Cancel
Save