Skip to content

Commit

Permalink
chore(services): minimize changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed Jun 1, 2023
1 parent 265ec18 commit 1f85724
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/app/Shared/Services/AuthCredentials.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface Credential {
export class AuthCredentials {
// TODO replace with Redux?
private readonly store = new Map<string, Credential>();

constructor(private readonly api: () => ApiService) {}

setCredential(targetId: string, username: string, password: string): Observable<boolean> {
Expand Down
18 changes: 9 additions & 9 deletions src/app/Shared/Services/Settings.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ export const automatedAnalysisConfigToRecordingAttributes = (
} as RecordingAttributes;
};
export class SettingsService {
constructor() {
this._featureLevel$.subscribe((featureLevel: FeatureLevel) => saveToLocalStorage('FEATURE_LEVEL', featureLevel));
this._visibleNotificationsCount$.subscribe((count: number) =>
saveToLocalStorage('VISIBLE_NOTIFICATIONS_COUNT', count)
);
this._datetimeFormat$.subscribe((format: DatetimeFormat) => saveToLocalStorage('DATETIME_FORMAT', format));
this._theme$.subscribe((theme: ThemeSetting) => saveToLocalStorage('THEME', theme));
}

private readonly _featureLevel$ = new BehaviorSubject<FeatureLevel>(
getFromLocalStorage('FEATURE_LEVEL', FeatureLevel.PRODUCTION)
);
Expand All @@ -101,6 +92,15 @@ export class SettingsService {

private readonly _theme$ = new BehaviorSubject<ThemeSetting>(getFromLocalStorage('THEME', ThemeSetting.AUTO));

constructor() {
this._featureLevel$.subscribe((featureLevel: FeatureLevel) => saveToLocalStorage('FEATURE_LEVEL', featureLevel));
this._visibleNotificationsCount$.subscribe((count: number) =>
saveToLocalStorage('VISIBLE_NOTIFICATIONS_COUNT', count)
);
this._datetimeFormat$.subscribe((format: DatetimeFormat) => saveToLocalStorage('DATETIME_FORMAT', format));
this._theme$.subscribe((theme: ThemeSetting) => saveToLocalStorage('THEME', theme));
}

media(query: string): Observable<MediaQueryList> {
const mediaQuery = window.matchMedia(query);
return fromEvent<MediaQueryList>(mediaQuery, 'change').pipe(startWith(mediaQuery));
Expand Down
4 changes: 2 additions & 2 deletions src/app/Shared/Services/Targets.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export class TargetsService {
private readonly api: ApiService,
private readonly notifications: Notifications,
login: LoginService,
private readonly notificationChannel: NotificationChannel
notificationChannel: NotificationChannel
) {
login
.getSessionState()
.pipe(concatMap((sessionState) => (sessionState === SessionState.USER_SESSION ? this.queryForTargets() : EMPTY)))
.subscribe(() => {
// just trigger a startup query
});
this.notificationChannel.messages(NotificationCategory.TargetJvmDiscovery).subscribe((v) => {
notificationChannel.messages(NotificationCategory.TargetJvmDiscovery).subscribe((v) => {
const evt: TargetDiscoveryEvent = v.message.event;
switch (evt.kind) {
case 'FOUND':
Expand Down
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import { App } from '@app/index';
import React from 'react';
import ReactDOM from 'react-dom';
Expand Down

0 comments on commit 1f85724

Please sign in to comment.