Skip to content

Commit 9d24649

Browse files
committed
PR feedback
1 parent e1b0b2c commit 9d24649

File tree

9 files changed

+38
-22
lines changed

9 files changed

+38
-22
lines changed

DEV.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,5 @@ https://www.kickstarter.com/projects/curtisclow/the-wild-cosmos-1-3-a-sci-fi-fan
181181
- Call service directly instead of using effects?
182182
- Use memoized `createSelector` functions for selectors
183183
- Debug with redux devtools to see what actions are being dispatched and how long they take
184+
- Add better trackBy functions for `*ngFor` directives
185+
- memoize expensive functions

packages/altair-app/src/app/modules/altair/altair.module.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ const providers = [
159159
WorkspaceEffects,
160160
ElectronEffects,
161161
]),
162-
StoreDevtoolsModule.instrument({
163-
logOnly: environment.production,
164-
}),
162+
!environment.production ? StoreDevtoolsModule.instrument() : [],
165163
TranslateModule.forRoot({
166164
loader: {
167165
provide: TranslateLoader,

packages/altair-app/src/app/modules/altair/components/query-editor/query-editor.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,9 @@ export class QueryEditorComponent implements OnInit, AfterViewInit, OnChanges {
188188
this.updateNewEditorDisableLineNumber(this.disableLineNumbers);
189189
}
190190

191-
if (changes?.query?.currentValue) {
191+
if (changes?.query?.currentValue && this.selectedIndex !== 0) {
192192
// Set current tab to Query if query is updated
193-
if (this.selectedIndex !== 0) {
194-
this.selectedIndex = 0;
195-
}
193+
this.selectedIndex = 0;
196194
}
197195

198196
if (changes?.shortcutMapping?.currentValue) {

packages/altair-app/src/app/modules/altair/components/query-result/query-result.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
>
134134
<div class="request-script-logs">
135135
<div class="request-script-logs__list">
136-
@for (item of requestScriptLogs; track item.time) {
136+
@for (item of requestScriptLogs; track item.id) {
137137
<div class="request-script-logs__line">
138138
<div class="request-script-logs__line-time">
139139
{{ item.time | date: 'mediumTime' }}

packages/altair-app/src/app/modules/altair/containers/window/window.component.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
catchError,
33
distinctUntilChanged,
44
map,
5+
shareReplay,
56
switchMap,
67
take,
78
withLatestFrom,
@@ -187,15 +188,16 @@ export class WindowComponent implements OnInit {
187188
select((state) => state.windowsMeta.activeWindowId)
188189
);
189190

190-
this.windowState$ = this.store.pipe(
191-
withLatestFrom(this.windowId$),
191+
this.windowState$ = this.windowId$.pipe(
192192
distinctUntilChanged(),
193-
map(([state, windowId]) => {
194-
return (
195-
fromRoot.selectWindowState(windowId)(state) ??
196-
fromRoot.getInitialPerWindowState()
197-
);
198-
})
193+
switchMap((windowId) =>
194+
this.store.pipe(
195+
select(fromRoot.selectWindowState(windowId)),
196+
distinctUntilChanged(),
197+
map((state) => state ?? fromRoot.getInitialPerWindowState())
198+
)
199+
),
200+
shareReplay(1)
199201
);
200202

201203
this.query$ = this.windowState$.pipe(select(fromRoot.getQueryState));
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
import { MockInstance } from 'ng-mocks';
12
import { CachedIfDirective } from './cached-if.directive';
3+
import { TemplateRef, ViewContainerRef } from '@angular/core';
4+
import { mock } from 'testing';
25

36
describe('CachedIfDirective', () => {
47
it('should create an instance', () => {
5-
const directive = new CachedIfDirective();
8+
const directive = new CachedIfDirective(
9+
// MockInstance(TemplateRef),
10+
// MockInstance(ViewContainerRef),
11+
mock(),
12+
mock()
13+
);
614
expect(directive).toBeTruthy();
715
});
816
});

packages/altair-app/src/app/modules/altair/directives/cached-if.directive.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import {
22
Directive,
33
EmbeddedViewRef,
44
Input,
5+
OnDestroy,
56
TemplateRef,
67
ViewContainerRef,
78
} from '@angular/core';
89

910
@Directive({
1011
selector: '[appCachedIf]',
1112
})
12-
export class CachedIfDirective {
13+
export class CachedIfDirective implements OnDestroy {
1314
private hasView = false;
1415
private cachedViewRef?: EmbeddedViewRef<unknown>;
1516

@@ -40,4 +41,10 @@ export class CachedIfDirective {
4041
}
4142
this.hasView = val;
4243
}
44+
ngOnDestroy(): void {
45+
if (this.cachedViewRef) {
46+
this.cachedViewRef.destroy();
47+
this.cachedViewRef = undefined;
48+
}
49+
}
4350
}

packages/altair-app/src/app/modules/altair/effects/query.effect.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,8 @@ export class QueryEffects {
346346
new queryActions.AppendRequestScriptLogsAction(
347347
response.windowId,
348348
[
349-
...new Set([
350-
...(preRequestScriptLogs || []),
351-
...(result?.transformedData?.requestScriptLogs || []),
352-
]),
349+
...(preRequestScriptLogs || []),
350+
...(result?.transformedData?.requestScriptLogs || []),
353351
]
354352
)
355353
);

packages/altair-core/jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ module.exports = {
99
},
1010
coverageDirectory: '<rootDir>/.coverage',
1111
collectCoverage: true,
12+
transformIgnorePatterns: [
13+
'node_modules/.pnpm/(?!@angular|@firebase|@ngrx|@sentry|lodash-es|altair-graphql-core|angular-resizable-element|angular-split|dexie|uuid|ngx-cookie-service|ngx-markdown|ky|color-name|json-schema-library|graphql-language-service|vscode-languageserver-types|cm6-graphql|ngx-toastr|@ngx-translate|lucide-angular|ng-zorro-antd|@ant-design\\+icons-angular|ngx-pipes)',
14+
],
1215
};

0 commit comments

Comments
 (0)