Skip to content

Commit

Permalink
Merge pull request #687 from csmith/master
Browse files Browse the repository at this point in the history
Fix counting of events.
  • Loading branch information
greboid committed Mar 13, 2016
2 parents abf98ac + 7dcdd5b commit 3836da6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/com/dmdirc/ui/messages/UnreadStatusManager.java
Expand Up @@ -27,6 +27,7 @@
import com.dmdirc.events.BaseChannelTextEvent;
import com.dmdirc.events.BaseQueryTextEvent;
import com.dmdirc.events.ChannelHighlightEvent;
import com.dmdirc.events.DisplayProperty;
import com.dmdirc.events.DisplayableEvent;
import com.dmdirc.events.QueryHighlightEvent;
import com.dmdirc.events.UnreadStatusChangedEvent;
Expand Down Expand Up @@ -61,39 +62,44 @@ public UnreadStatusManager(final WindowModel container) {

@Handler
public void handleDisplayableEvent(final DisplayableEvent event) {
if (event.getSource().equals(container)) {
if (includeEvent(event)) {
updateStatus(miscellaneousColour, unreadLines + 1);
}
}

@Handler
public void handleChannelTextEvent(final BaseChannelTextEvent event) {
if (event.getSource().equals(container)) {
if (includeEvent(event)) {
updateStatus(messageColour);
}
}

@Handler
public void handleQueryTextEvent(final BaseQueryTextEvent event) {
if (event.getSource().equals(container)) {
if (includeEvent(event)) {
updateStatus(messageColour);
}
}

@Handler
public void handleChannelHighlightEvent(final ChannelHighlightEvent event) {
if (event.getChannel().equals(container)) {
if (includeEvent(event)) {
updateStatus(highlightColour);
}
}

@Handler
public void handleQueryHighlightEvent(final QueryHighlightEvent event) {
if (event.getQuery().equals(container)) {
if (includeEvent(event)) {
updateStatus(highlightColour);
}
}

private boolean includeEvent(final DisplayableEvent event) {
return event.getSource().equals(container)
&& !event.getDisplayProperty(DisplayProperty.DO_NOT_DISPLAY).orElse(false);
}

public int getUnreadLines() {
return unreadLines;
}
Expand Down

0 comments on commit 3836da6

Please sign in to comment.