Limit number of messages in widget

pull/207/head
M66B 3 years ago
parent c1e3b5db9a
commit 4dbc809480

@ -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" +

@ -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 {

Loading…
Cancel
Save