mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-02 11:01:23 +01:00
Added account to local contacts
This commit is contained in:
@@ -31,17 +31,20 @@ import androidx.room.Update;
|
||||
|
||||
@Dao
|
||||
public interface DaoContact {
|
||||
@Query("SELECT * FROM contact")
|
||||
List<EntityContact> getContacts();
|
||||
|
||||
@Query("SELECT * FROM contact" +
|
||||
" WHERE account = :account")
|
||||
List<EntityContact> getContacts(long account);
|
||||
|
||||
@Query("SELECT contact.*, account.name AS accountName" +
|
||||
" FROM contact" +
|
||||
" JOIN account ON account.id = contact.account" +
|
||||
" ORDER BY times_contacted DESC, last_contacted DESC")
|
||||
LiveData<List<EntityContact>> liveContacts();
|
||||
LiveData<List<TupleContactEx>> liveContacts();
|
||||
|
||||
@Query("SELECT * FROM contact" +
|
||||
" WHERE favorite <> " + EntityContact.STATE_IGNORE +
|
||||
" WHERE state <> " + EntityContact.STATE_IGNORE +
|
||||
" ORDER BY" +
|
||||
" CASE WHEN favorite = " + EntityContact.STATE_FAVORITE + " THEN 0 ELSE 1 END" +
|
||||
" CASE WHEN state = " + EntityContact.STATE_FAVORITE + " THEN 0 ELSE 1 END" +
|
||||
", times_contacted DESC" +
|
||||
", last_contacted DESC" +
|
||||
" LIMIT :count")
|
||||
@@ -49,9 +52,10 @@ public interface DaoContact {
|
||||
|
||||
@Query("SELECT *" +
|
||||
" FROM contact" +
|
||||
" WHERE email = :email" +
|
||||
" AND (:type IS NULL OR type = :type)")
|
||||
EntityContact getContact(Integer type, String email);
|
||||
" WHERE account = :account" +
|
||||
" AND type = :type" +
|
||||
" AND email = :email")
|
||||
EntityContact getContact(long account, int type, String email);
|
||||
|
||||
@Query("SELECT id AS _id, name, email" +
|
||||
", CASE type" +
|
||||
@@ -60,9 +64,10 @@ public interface DaoContact {
|
||||
" ELSE '?'" +
|
||||
" END AS type" +
|
||||
" FROM contact" +
|
||||
" WHERE name LIKE :name" +
|
||||
" AND (:type IS NULL OR type = :type)")
|
||||
Cursor searchContacts(Integer type, String name);
|
||||
" WHERE (:account IS NULL OR account = :account)" +
|
||||
" AND (:type IS NULL OR type = :type)" +
|
||||
" AND (email LIKE :query COLLATE NOCASE OR name LIKE :query COLLATE NOCASE)")
|
||||
Cursor searchContacts(Long account, Integer type, String query);
|
||||
|
||||
@Insert
|
||||
long insertContact(EntityContact contact);
|
||||
@@ -70,13 +75,13 @@ public interface DaoContact {
|
||||
@Update
|
||||
int updateContact(EntityContact contact);
|
||||
|
||||
@Query("UPDATE contact SET favorite = :state WHERE id = :id")
|
||||
@Query("UPDATE contact SET state = :state WHERE id = :id")
|
||||
int setContactState(long id, int state);
|
||||
|
||||
@Query("DELETE FROM contact" +
|
||||
" WHERE last_contacted IS NOT NULL" +
|
||||
" AND last_contacted < :before" +
|
||||
" AND favorite <> " + EntityContact.STATE_FAVORITE)
|
||||
" AND state <> " + EntityContact.STATE_FAVORITE)
|
||||
int deleteContacts(long before);
|
||||
|
||||
@Query("DELETE FROM contact")
|
||||
|
||||
Reference in New Issue
Block a user