diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index b063f15a40..1a236b2e05 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -607,8 +607,9 @@ public interface DaoMessage { " AND (NOT :flagged OR message.ui_flagged)" + " GROUP BY account.id" + ", CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + - " ORDER BY message.received DESC") - List getWidgetUnified(Long account, Long folder, boolean threading, boolean unseen, boolean flagged); + " ORDER BY message.received DESC" + + " LIMIT :limit") + List getWidgetUnified(Long account, Long folder, boolean threading, boolean unseen, boolean flagged, int limit); @Query("SELECT uid FROM message" + " WHERE folder = :folder" + diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index 4182a29690..244ddb7e38 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -77,6 +77,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot private boolean allColors; private List messages = new ArrayList<>(); + private static final int MAX_WIDGET_MESSAGES = 500; + WidgetUnifiedRemoteViewsFactory(final Context context, Intent intent) { this.context = context; this.appWidgetId = intent.getIntExtra( @@ -143,7 +145,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot messages = db.message().getWidgetUnified( account < 0 ? null : account, folder < 0 ? null : folder, - threading, unseen, flagged); + threading, unseen, flagged, + MAX_WIDGET_MESSAGES); db.setTransactionSuccessful(); } finally {