Browse Source

WindowStatusPlugin fixes.

 - Use correct config binding names so that `shownone` actually works again.
 - Update the status on any channeluser mode changes not just window changes.
pull/529/head
Shane Mc Cormack 7 years ago
parent
commit
84083ebcfa

+ 11
- 4
windowstatus/src/main/java/com/dmdirc/addons/windowstatus/WindowStatusManager.java View File

@@ -32,6 +32,7 @@ import com.dmdirc.config.prefs.PreferencesCategory;
32 32
 import com.dmdirc.config.prefs.PreferencesDialogModel;
33 33
 import com.dmdirc.config.prefs.PreferencesSetting;
34 34
 import com.dmdirc.config.prefs.PreferencesType;
35
+import com.dmdirc.events.ChannelUserModeChangeEvent;
35 36
 import com.dmdirc.events.ClientPrefsOpenedEvent;
36 37
 import com.dmdirc.events.StatusBarComponentAddedEvent;
37 38
 import com.dmdirc.events.StatusBarComponentRemovedEvent;
@@ -90,6 +91,7 @@ public class WindowStatusManager {
90 91
         panel = UIUtilities.invokeAndWait(WindowStatusPanel::new);
91 92
         eventBus.publishAsync(new StatusBarComponentAddedEvent(panel));
92 93
         swingEventBus.subscribe(this);
94
+        eventBus.subscribe(this);
93 95
         configBinder.bind(this, WindowStatusManager.class);
94 96
         UIUtilities.invokeLater(this::updateStatus);
95 97
     }
@@ -99,6 +101,7 @@ public class WindowStatusManager {
99 101
      */
100 102
     public void onUnload() {
101 103
         swingEventBus.unsubscribe(this);
104
+        eventBus.unsubscribe(this);
102 105
         eventBus.publishAsync(new StatusBarComponentRemovedEvent(panel));
103 106
         configBinder.unbind(this);
104 107
         panel = null;
@@ -109,6 +112,11 @@ public class WindowStatusManager {
109 112
         event.getWindow().map(TextFrame::getContainer).ifPresent(this::updateStatus);
110 113
     }
111 114
 
115
+    @Handler
116
+    public void usermodeChange(final ChannelUserModeChangeEvent event) {
117
+        updateStatus();
118
+    }
119
+
112 120
     /** Update the window status using the current active window. */
113 121
     public void updateStatus() {
114 122
         activeFrameManager.getActiveFrame().ifPresent(c -> updateStatus(c.getContainer()));
@@ -168,8 +176,7 @@ public class WindowStatusManager {
168 176
                 if (!isFirst) {
169 177
                     textString.append(' ');
170 178
                 }
171
-                final String name = i > 0 ?
172
-                        Character.toString(channelUserModes.charAt(i)) : nonePrefix;
179
+                final String name = i > 0 ? Character.toString(channelUserModes.charAt(i)) : nonePrefix;
173 180
                 textString.append(name).append(count);
174 181
                 isFirst = false;
175 182
             }
@@ -199,13 +206,13 @@ public class WindowStatusManager {
199 206
         updateStatus();
200 207
     }
201 208
 
202
-    @ConfigBinding(key = "client.shownone", invocation = EDTInvocation.class)
209
+    @ConfigBinding(key = "channel.shownone", invocation = EDTInvocation.class)
203 210
     public void handleShowNone(final String value) {
204 211
         shownone = Boolean.valueOf(value);
205 212
         updateStatus();
206 213
     }
207 214
 
208
-    @ConfigBinding(key = "client.noneprefix", invocation = EDTInvocation.class)
215
+    @ConfigBinding(key = "channel.noneprefix", invocation = EDTInvocation.class)
209 216
     public void handleShowPrefix(final String value) {
210 217
         nonePrefix = value;
211 218
         updateStatus();

Loading…
Cancel
Save