Skip to content

Commit

Permalink
Add auth state dedup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
taldekar committed Jan 22, 2025
1 parent dc8b198 commit a316ac0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private <T, R> void processQueuedEvents(final String interestId, final Class<R>

List<R> eventBatchQueue = new ArrayList<>(EVENT_BATCH_SIZE);

while (eventQueue.drainTo(eventBatchQueue) > 0) {
while (eventQueue.drainTo(eventBatchQueue, EVENT_BATCH_SIZE) > 0) {
for (R newEvent : eventBatchQueue) {
try {
eventCallback.callWith(newEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public final class DefaultAuthStateManager implements AuthStateManager {
private LoginParams loginParams; // used in login's getSsoToken params
private String issuerUrl; // used in AmazonQLspClientImpl.getConnectionMetadata()
private String ssoTokenId; // used in logout's invalidateSsoToken params
private AuthState previousAuthState;

public DefaultAuthStateManager(final PluginStore pluginStore) {
previousAuthState = null;
this.authPluginStore = new AuthPluginStore(pluginStore);
syncAuthStateWithPluginStore();
}
Expand Down Expand Up @@ -120,7 +122,12 @@ private void updateState(final AuthStateType authStatusType, final LoginType log
* This notification is critical for ensuring all plugin components reflect the current
* authentication state.
*/
EventBroker.getInstance().post(getAuthState());
AuthState currentAuthState = getAuthState();
if (!currentAuthState.equals(previousAuthState)) {
EventBroker.getInstance().post(getAuthState());
previousAuthState = currentAuthState;
}

}

private void syncAuthStateWithPluginStore() {
Expand Down

0 comments on commit a316ac0

Please sign in to comment.