mirror of
https://github.com/invoke-ai/InvokeAI
synced 2026-03-23 07:10:33 +01:00
feat(ui): add flag for connected status
This commit is contained in:
parent
437594915a
commit
d04fc343f0
@ -127,6 +127,7 @@ describe('AppNavigationApi', () => {
|
||||
|
||||
describe('Basic Connection', () => {
|
||||
it('should connect to app', () => {
|
||||
expect(navigationApi.$isConnected.get()).toBe(false);
|
||||
navigationApi.connectToApp(mockAppApi);
|
||||
|
||||
expect(navigationApi._app).not.toBeNull();
|
||||
@ -135,6 +136,7 @@ describe('AppNavigationApi', () => {
|
||||
expect(navigationApi._app?.storage.set).toBe(mockSetStorage);
|
||||
expect(navigationApi._app?.storage.get).toBe(mockGetStorage);
|
||||
expect(navigationApi._app?.storage.delete).toBe(mockDeleteStorage);
|
||||
expect(navigationApi.$isConnected.get()).toBe(true);
|
||||
});
|
||||
|
||||
it('should disconnect from app', () => {
|
||||
@ -142,6 +144,7 @@ describe('AppNavigationApi', () => {
|
||||
navigationApi.disconnectFromApp();
|
||||
|
||||
expect(navigationApi._app).toBeNull();
|
||||
expect(navigationApi.$isConnected.get()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -112,6 +112,12 @@ export class NavigationApi {
|
||||
*/
|
||||
_app: NavigationAppApi | null = null;
|
||||
|
||||
/**
|
||||
* A flag indicating if the application is currently connected to the navigation API.
|
||||
*/
|
||||
private _$isConnected = atom(false);
|
||||
$isConnected: Atom<boolean> = this._$isConnected;
|
||||
|
||||
/**
|
||||
* Connect to the application to manage tab switching.
|
||||
* @param api - The application API that provides methods to set and get the current app tab and manage panel
|
||||
@ -119,6 +125,7 @@ export class NavigationApi {
|
||||
*/
|
||||
connectToApp = (api: NavigationAppApi): void => {
|
||||
this._app = api;
|
||||
this._$isConnected.set(true);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -126,6 +133,7 @@ export class NavigationApi {
|
||||
*/
|
||||
disconnectFromApp = (): void => {
|
||||
this._app = null;
|
||||
this._$isConnected.set(false);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user