Skip to content

Commit

Permalink
Change to just listen to binary state
Browse files Browse the repository at this point in the history
  • Loading branch information
ofekby committed Dec 4, 2023
1 parent 13347cc commit a256003
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/enterprise/tabnineChatWidget/SelfHostedChatEnabledState.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ExtensionContext, authentication } from "vscode";
import { ExtensionContext } from "vscode";
import ChatEnabledState, {
ChatEnabledStateData,
ChatStates,
} from "../../tabnineChatWidget/ChatEnabledState";
import EventEmitterBasedNonNullState from "../../state/EventEmitterBasedNonNullState";
import getUserInfo from "../requests/UserInfo";
import { useDerviedState } from "../../state/deriveState";
import BINARY_STATE from "../../binary/binaryStateSingleton";

export default class SelfHostedChatEnabledState
Expand All @@ -13,18 +14,14 @@ export default class SelfHostedChatEnabledState
constructor(context: ExtensionContext) {
super(ChatStates.loading);

const stateListenDisposable = BINARY_STATE.onChange(() => {
void this.updateState();

if (stateListenDisposable) {
stateListenDisposable.dispose();
}
});

context.subscriptions.push(
authentication.onDidChangeSessions(() => {
void this.updateState();
})
useDerviedState(
BINARY_STATE,
(state) => state.is_logged_in,
() => {
void this.updateState();
}
)
);
}

Expand Down

0 comments on commit a256003

Please sign in to comment.