Only fetch and display a given notification once (#3626)
When fetching:
- Maintain a marker with the position of the newest fetched notification
- Use the marker to determine which notifications to fetch
- Fetch notifications with min_id to ensure that none are lost
- Update the marker as necessary
- Perform a one-time immediate fetch of notifications on startup
When creating notifications:
- Identify each notification with tag=${MastodonNotificationId}, id=${account.id}
- Remove activeNotifications field, it's no longer necessary
- Use the tag/id tuple to reliably identify existing notifications and avoid creating duplicates
- Cancelling notifications for an account must iterate over all the notifications, and individually remove the notifications that exist for that account.
- Limit notifications to a maximum of 40 (excluding summary notifications)
- Remove notifications (oldest first) to get under this limit
- Rate limit notification creation to 1 per second, so the OS won't drop them
Adjust the summary notification:
- Ensure the summary notification and the child notifications have the same group key
- Dismiss the summary notification if there is only one child notification
NotificationClearBroadcastReceiver is no longer needed, so remove it, and the need for deletePendingIntent.
Fixes #3625, #3539
This commit is contained in:
parent
74a00c0591
commit
81b15e72f3
11 changed files with 1327 additions and 197 deletions
|
|
@ -18,7 +18,9 @@ package com.keylesspalace.tusky.db;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.room.AutoMigration;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.DeleteColumn;
|
||||
import androidx.room.RoomDatabase;
|
||||
import androidx.room.migration.AutoMigrationSpec;
|
||||
import androidx.room.migration.Migration;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
|
||||
|
|
@ -39,9 +41,10 @@ import java.io.File;
|
|||
TimelineAccountEntity.class,
|
||||
ConversationEntity.class
|
||||
},
|
||||
version = 49,
|
||||
version = 50,
|
||||
autoMigrations = {
|
||||
@AutoMigration(from = 48, to = 49)
|
||||
@AutoMigration(from = 48, to = 49),
|
||||
@AutoMigration(from = 49, to = 50, spec = AppDatabase.MIGRATION_49_50.class)
|
||||
}
|
||||
)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
|
|
@ -665,4 +668,7 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE `TimelineStatusEntity` ADD COLUMN `filtered` TEXT");
|
||||
}
|
||||
};
|
||||
|
||||
@DeleteColumn(tableName = "AccountEntity", columnName = "activeNotifications")
|
||||
static class MIGRATION_49_50 implements AutoMigrationSpec { }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue