Skip to content

Commit

Permalink
refactor: Remove all .removeFirst() & .removeLast() (#2124)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne authored Dec 16, 2024
2 parents 50b64d8 + a0739f9 commit 7e0b21b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object FlatteningSubBodiesSerializer : JsonTransformingSerializer<RealmList<SubB
outputList: MutableList<JsonElement> = mutableListOf(),
): List<JsonElement> {

val remoteSubBody = inputList.removeFirst() as? JsonObject
val remoteSubBody = inputList.removeAt(0) as? JsonObject
val remoteBody = remoteSubBody?.get("body") as? JsonObject
val remoteSubBodies = remoteBody?.get("subBody") as? JsonArray

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class FolderController @Inject constructor(
suspend fun updateFolderAndChildren(id: String, realm: Realm, onUpdate: (Folder) -> Unit) {

tailrec fun updateChildrenRecursively(inputList: MutableList<Folder>) {
val folder = inputList.removeFirst()
val folder = inputList.removeAt(0)
onUpdate(folder)
inputList.addAll(folder.children)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class Message : RealmObject {
fun shouldBeExpanded(index: Int, lastIndex: Int) = !isDraft && (!isSeen || index == lastIndex)

fun toThread() = Thread().apply {
uid = this@Message.uid // TODO: Check if we can use random UUID instead ?
uid = this@Message.uid
folderId = this@Message.folderId
messagesIds += this@Message.messageIds
messages += this@Message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RecentSearchAdapter(

while (count() > MAX_HISTORY_COUNT) {
notifyItemRemoved(lastIndex)
removeLast()
removeAt(lastIndex)
}

return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ fun List<Folder>.flattenFolderChildrenAndRemoveMessages(dismissHiddenChildren: B
outputList: MutableList<Folder> = mutableListOf(),
): List<Folder> {

val folder = inputList.removeFirst()
val folder = inputList.removeAt(0)

val children = if (folder.isManaged()) {
outputList.add(folder.copyFromRealm(depth = 1u))
Expand Down

0 comments on commit 7e0b21b

Please sign in to comment.