Limit number of messages in widget

This commit is contained in:
M66B 2022-05-02 11:07:36 +02:00
parent c1e3b5db9a
commit 4dbc809480
2 changed files with 7 additions and 3 deletions

View File

@ -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<TupleMessageWidget> getWidgetUnified(Long account, Long folder, boolean threading, boolean unseen, boolean flagged);
" ORDER BY message.received DESC" +
" LIMIT :limit")
List<TupleMessageWidget> getWidgetUnified(Long account, Long folder, boolean threading, boolean unseen, boolean flagged, int limit);
@Query("SELECT uid FROM message" +
" WHERE folder = :folder" +

View File

@ -77,6 +77,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
private boolean allColors;
private List<TupleMessageWidget> 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 {