Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ab1e6d6 authored by Selim Cinek's avatar Selim Cinek Committed by Lucas Dupin
Browse files

Fixed a bug where the media entries are invisible after switching users

Because the list was only cleared after notifying the listeners,
their checks if we still have active players was using an old
state.

Bug: 158367094
Test: add media, switch users
Change-Id: I524cadfd02967e7bd017ebf4cee2beb5bfaef26d
parent 9401591b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -193,12 +193,15 @@ class MediaDataManager(
    private fun clearData() {
        // Called on user change. Remove all current MediaData objects and inform listeners
        val listenersCopy = listeners.toSet()
        mediaEntries.forEach {
        val keyCopy = mediaEntries.keys.toMutableList()
        // Clear the list first, to make sure callbacks from listeners if we have any entries
        // are up to date
        mediaEntries.clear()
        keyCopy.forEach {
            listenersCopy.forEach { listener ->
                listener.onMediaDataRemoved(it.key)
                listener.onMediaDataRemoved(it)
            }
        }
        mediaEntries.clear()
    }

    private fun removeAllForPackage(packageName: String) {