Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: clear notifications from the db after logging out #4944

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/org/wikipedia/WikipediaApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.wikipedia.appshortcuts.AppShortcuts
import org.wikipedia.auth.AccountUtil
import org.wikipedia.concurrency.FlowEventBus
import org.wikipedia.connectivity.ConnectionStateMonitor
import org.wikipedia.database.AppDatabase
import org.wikipedia.dataclient.ServiceFactory
import org.wikipedia.dataclient.SharedPreferenceCookieManager
import org.wikipedia.dataclient.WikiSite
Expand Down Expand Up @@ -251,6 +252,7 @@ class WikipediaApp : Application() {
ServiceFactory.get(wikiSite).postLogout(token)
}.invokeOnCompletion {
SharedPreferenceCookieManager.instance.clearAllCookies()
AppDatabase.instance.notificationDao().deleteAll()
L.d("Logout complete.")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.wikipedia.notifications.db

import androidx.room.*
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import kotlinx.coroutines.flow.Flow

@Dao
Expand All @@ -14,6 +19,9 @@ interface NotificationDao {
@Delete
suspend fun deleteNotification(notification: Notification)

@Query("DELETE FROM Notification")
fun deleteAll()

@Query("SELECT * FROM Notification")
fun getAllNotifications(): List<Notification>

Expand Down
Loading