-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/fga/simplify timeline logic (#6318)
* Sync: delete all previous chunks in case of gappy sync * Chunk: dont link chunks if we find existing timeline event (keep multiple timeline events in db) * Timeline : remove some unused code * Clean and add changelog * Timeline: set named argument * Timeline: avoid restarting the timeline when there is a CancellationException due to permalink * Timeline: add migration to clean up old (broken) chunks * Update matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo030.kt Co-authored-by: Benoit Marty <[email protected]> * Timeline: try to fix test * ignoring broken instrumentation test in order to release Co-authored-by: ganfra <[email protected]> Co-authored-by: Benoit Marty <[email protected]> Co-authored-by: Adam Brown <[email protected]>
- Loading branch information
1 parent
41431cd
commit b07e0a4
Showing
14 changed files
with
107 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix loop in timeline and simplify management of chunks and timeline events. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...d/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo030.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2022 The Matrix.org Foundation C.I.C. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.matrix.android.sdk.internal.database.migration | ||
|
||
import io.realm.DynamicRealm | ||
import org.matrix.android.sdk.internal.database.model.ChunkEntityFields | ||
import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields | ||
import org.matrix.android.sdk.internal.extensions.clearWith | ||
import org.matrix.android.sdk.internal.util.database.RealmMigrator | ||
|
||
/** | ||
* Migrating to: | ||
* Cleaning old chunks which may have broken links. | ||
*/ | ||
internal class MigrateSessionTo030(realm: DynamicRealm) : RealmMigrator(realm, 30) { | ||
|
||
override fun doMigrate(realm: DynamicRealm) { | ||
// Delete all previous chunks | ||
val chunks = realm.where("ChunkEntity") | ||
.equalTo(ChunkEntityFields.IS_LAST_FORWARD, false) | ||
.findAll() | ||
|
||
chunks.forEach { chunk -> | ||
chunk.getList(ChunkEntityFields.TIMELINE_EVENTS.`$`).clearWith { timelineEvent -> | ||
// Don't delete state events | ||
if (timelineEvent.isNull(TimelineEventEntityFields.ROOT.STATE_KEY)) { | ||
timelineEvent.getObject(TimelineEventEntityFields.ROOT.`$`)?.deleteFromRealm() | ||
timelineEvent.deleteFromRealm() | ||
} | ||
} | ||
chunk.deleteFromRealm() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.