Skip to content

Commit

Permalink
Handle _buffer_cleared
Browse files Browse the repository at this point in the history
Fixes some of #577
  • Loading branch information
oakkitten committed Feb 23, 2024
1 parent da63de3 commit add9984
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/src/main/java/com/ubergeek42/WeechatAndroid/relay/Buffer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.ubergeek42.WeechatAndroid.utils.updatable
import com.ubergeek42.cats.Cat
import com.ubergeek42.cats.Kitty
import com.ubergeek42.cats.Root
import java.util.*

class Buffer @WorkerThread constructor(
@JvmField val pointer: Long,
Expand Down Expand Up @@ -209,7 +208,7 @@ class Buffer @WorkerThread constructor(
/////////////////////////////////////////////////////////////// stuff called by message handlers
////////////////////////////////////////////////////////////////////////////////////////////////

@WorkerThread @Synchronized fun replaceLines(newLines: Collection<Line>) {
@WorkerThread fun replaceLines(newLines: Collection<Line>) {
if (isOpen) {
newLines.forEach { it.ensureSpannable() }
}
Expand Down Expand Up @@ -366,6 +365,14 @@ class Buffer @WorkerThread constructor(
bufferEyes.forEach { it.onLinesListed() }
}

@WorkerThread fun onLinesCleared() {
synchronized(this) {
lines = Lines().apply { status = Lines.Status.EverythingFetched }
resetUnreadsAndHighlights()
}
bufferEyes.forEach { it.onLinesListed() }
}

@WorkerThread fun onBufferClosed() {
synchronized(this) {
unreads = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ object BufferList {
}
}

add("_buffer_cleared") { obj, _ ->
obj.forEachExistingBuffer { _, buffer ->
buffer.onLinesCleared()
}
}

return handlers
}

Expand Down

0 comments on commit add9984

Please sign in to comment.