Skip to content

Commit 3e10952

Browse files
committed
feat: onpush strategy
1 parent 92add4d commit 3e10952

File tree

342 files changed

+2266
-2035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+2266
-2035
lines changed

src/app/about/about.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AsyncPipe, DecimalPipe} from '@angular/common';
2-
import {Component, inject, OnInit} from '@angular/core';
2+
import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
33
import {Router, RouterLink} from '@angular/router';
44
import {APIUser} from '@grpc/spec.pb';
55
import {StatisticsClient} from '@grpc/spec.pbsc';
@@ -81,6 +81,7 @@ You can support our project by [finances](/donate) or [moral](/feedback).
8181
Take part in [the translation of the site](https://github.com/autowp/autowp-frontend/tree/master/src/locale) into other languages.`;
8282

8383
@Component({
84+
changeDetection: ChangeDetectionStrategy.OnPush,
8485
imports: [RouterLink, AsyncPipe],
8586
providers: [BytesPipe],
8687
selector: 'app-about',

src/app/account/access/access.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import {Component, inject, OnInit} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
22
import {RouterLink} from '@angular/router';
33
import {environment} from '@environment/environment';
44
import {PageEnvService} from '@services/page-env.service';
55

66
@Component({
7+
changeDetection: ChangeDetectionStrategy.OnPush,
78
imports: [RouterLink],
89
selector: 'app-account-access',
910
templateUrl: './access.component.html',

src/app/account/account.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AsyncPipe} from '@angular/common';
2-
import {Component, inject} from '@angular/core';
2+
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
33
import {RouterLink, RouterOutlet} from '@angular/router';
44
import {ForumsClient} from '@grpc/spec.pbsc';
55
import {Empty} from '@ngx-grpc/well-known-types';
@@ -24,6 +24,7 @@ interface SidebarItem {
2424
}
2525

2626
@Component({
27+
changeDetection: ChangeDetectionStrategy.OnPush,
2728
imports: [RouterLink, RouterOutlet, AsyncPipe],
2829
selector: 'app-account',
2930
templateUrl: './account.component.html',

src/app/account/accounts/accounts.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h1 i18n>My accounts</h1>
33
</div>
44
@if (accounts$ | async; as accounts) {
5-
@if (accounts.length > 0 && !disconnectFailed) {
5+
@if (accounts.length > 0 && !disconnectFailed()) {
66
<div class="card card-body mb-4">
77
@for (account of accounts; track account.id) {
88
<div>
@@ -33,13 +33,13 @@ <h1 i18n>My accounts</h1>
3333
}
3434
}
3535

36-
@if (disconnectFailed) {
36+
@if (disconnectFailed()) {
3737
<div class="card card-body">
3838
<app-markdown
3939
i18n-markdown
4040
markdown="Не удалось удалить учетную запись.
4141
4242
Такое бывает, если привязанная учётная запись является единственным способом авторизации, т.е. не задан e-mail или другие учётный записи."
43-
></app-markdown>
43+
/>
4444
</div>
4545
}

src/app/account/accounts/accounts.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AsyncPipe} from '@angular/common';
2-
import {Component, inject, OnInit} from '@angular/core';
2+
import {ChangeDetectionStrategy, Component, inject, OnInit, signal} from '@angular/core';
33
import {APIAccountsAccount, DeleteUserAccountRequest} from '@grpc/spec.pb';
44
import {UsersClient} from '@grpc/spec.pbsc';
55
import {Empty} from '@ngx-grpc/well-known-types';
@@ -11,6 +11,7 @@ import {catchError, map} from 'rxjs/operators';
1111
import {ToastsService} from '../../toasts/toasts.service';
1212

1313
@Component({
14+
changeDetection: ChangeDetectionStrategy.OnPush,
1415
imports: [MarkdownComponent, AsyncPipe],
1516
selector: 'app-account-accounts',
1617
templateUrl: './accounts.component.html',
@@ -32,7 +33,7 @@ export class AccountAccountsComponent implements OnInit {
3233
map(([response]) => response.items || []),
3334
);
3435

35-
protected disconnectFailed = false;
36+
protected readonly disconnectFailed = signal(false);
3637

3738
ngOnInit(): void {
3839
setTimeout(() => this.#pageEnv.set({pageId: 123}), 0);
@@ -41,7 +42,7 @@ export class AccountAccountsComponent implements OnInit {
4142
protected remove(account: APIAccountsAccount) {
4243
this.#usersClient.deleteUserAccount(new DeleteUserAccountRequest({id: account.id})).subscribe({
4344
error: (response: unknown) => {
44-
this.disconnectFailed = true;
45+
this.disconnectFailed.set(true);
4546
this.#toastService.handleError(response);
4647
},
4748
next: () => {

src/app/account/contacts/contacts.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1 i18n>Contacts</h1>
2323
<div class="flex-grow-1">
2424
<button class="btn-close float-end" (click)="deleteContact(contact.user.id)"></button>
2525
<h4>
26-
<app-user [user]="contact.user"></app-user>
26+
<app-user [user]="contact.user" />
2727
</h4>
2828
@if (contact.user.lastOnline) {
2929
<p

src/app/account/contacts/contacts.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AsyncPipe, DatePipe} from '@angular/common';
2-
import {Component, inject, OnInit} from '@angular/core';
2+
import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
33
import {RouterLink} from '@angular/router';
44
import {Contact, DeleteContactRequest} from '@grpc/spec.pb';
55
import {ContactsClient} from '@grpc/spec.pbsc';
@@ -17,6 +17,7 @@ import {ToastsService} from '../../toasts/toasts.service';
1717
import {UserComponent} from '../../user/user/user.component';
1818

1919
@Component({
20+
changeDetection: ChangeDetectionStrategy.OnPush,
2021
imports: [RouterLink, UserComponent, NgbTooltip, AsyncPipe, DatePipe, TimeAgoPipe],
2122
selector: 'app-account-contacts',
2223
templateUrl: './contacts.component.html',

src/app/account/delete/delete.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@ <h1 i18n>Account delete</h1>
99
Нажав на красную кнопку, все данные, касающиеся вас, будут обезличены или удалены.
1010
1111
Этот процесс необратим, поэтому хорошенько подумайте и не принимайте поспешных решений."
12-
></app-markdown>
12+
/>
1313
<hr />
1414
<form class="form-horizontal" (submit)="submit()">
1515
<div class="mb-3 row">
1616
<label class="col-md-2 col-form-label" for="password_old" i18n="@@user/password">Password</label>
1717
<div class="col-md-10">
1818
<input
19+
id="password_old"
1920
type="password"
2021
size="50"
2122
maxlength="50"
2223
name="password_old"
2324
class="form-control"
2425
[(ngModel)]="form.password_old"
25-
[class.is-invalid]="invalidParams && invalidParams['password_old']"
26+
[class.is-invalid]="invalidParams() && invalidParams()['password_old']"
2627
/>
27-
@for (message of invalidParams | invalidParams: 'password_old'; track message) {
28+
@for (message of invalidParams() | invalidParams: 'password_old'; track message) {
2829
<p [textContent]="message" class="invalid-feedback"></p>
2930
}
3031
</div>

src/app/account/delete/delete.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, inject, OnInit} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component, inject, OnInit, signal} from '@angular/core';
22
import {FormsModule} from '@angular/forms';
33
import {Router} from '@angular/router';
44
import {APIDeleteUserRequest} from '@grpc/spec.pb';
@@ -15,6 +15,7 @@ import {extractFieldViolations, fieldViolations2InvalidParams} from '../../grpc'
1515
import {ToastsService} from '../../toasts/toasts.service';
1616

1717
@Component({
18+
changeDetection: ChangeDetectionStrategy.OnPush,
1819
imports: [MarkdownComponent, FormsModule, InvalidParamsPipe],
1920
selector: 'app-account-delete',
2021
templateUrl: './delete.component.html',
@@ -29,7 +30,7 @@ export class AccountDeleteComponent implements OnInit {
2930
protected readonly form = {
3031
password_old: '',
3132
};
32-
protected invalidParams?: InvalidParams;
33+
protected readonly invalidParams = signal<InvalidParams>({});
3334

3435
ngOnInit(): void {
3536
setTimeout(() => this.#pageEnv.set({pageId: 137}), 0);
@@ -54,7 +55,7 @@ export class AccountDeleteComponent implements OnInit {
5455
this.#toastService.handleError(response);
5556
if (response instanceof GrpcStatusEvent && response.statusCode === 3) {
5657
const fieldViolations = extractFieldViolations(response);
57-
this.invalidParams = fieldViolations2InvalidParams(fieldViolations);
58+
this.invalidParams.set(fieldViolations2InvalidParams(fieldViolations));
5859
}
5960
},
6061
next: () => {

src/app/account/delete/deleted/deleted.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ <h1 i18n>Account removed</h1>
77
i18n-markdown
88
markdown="Account removed.
99
Good luck."
10-
></app-markdown>
10+
/>
1111
</div>

src/app/account/delete/deleted/deleted.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {Component, inject, OnInit} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
22
import {PageEnvService} from '@services/page-env.service';
33
import {MarkdownComponent} from '@utils/markdown/markdown.component';
44

55
@Component({
6+
changeDetection: ChangeDetectionStrategy.OnPush,
67
imports: [MarkdownComponent],
78
selector: 'app-account-delete-deleted',
89
templateUrl: './deleted.component.html',

src/app/account/email/email.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AsyncPipe} from '@angular/common';
2-
import {Component, inject, OnInit} from '@angular/core';
2+
import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
33
import {environment} from '@environment/environment';
44
import {APIMeRequest, UserFields} from '@grpc/spec.pb';
55
import {UsersClient} from '@grpc/spec.pbsc';
@@ -10,6 +10,7 @@ import {catchError, map} from 'rxjs/operators';
1010
import {ToastsService} from '../../toasts/toasts.service';
1111

1212
@Component({
13+
changeDetection: ChangeDetectionStrategy.OnPush,
1314
imports: [AsyncPipe],
1415
selector: 'app-account-email',
1516
templateUrl: './email.component.html',

src/app/account/inbox-pictures/inbox-pictures.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h1 i18n>Unmoderated</h1>
55
<div class="row">
66
@for (picture of data.items || []; track picture.id) {
77
<div class="col-12 cols-sm-6 col-md-6 col-lg-4">
8-
<app-thumbnail [picture]="picture" [route]="['/picture', picture.identity]"></app-thumbnail>
8+
<app-thumbnail [picture]="picture" [route]="['/picture', picture.identity]" />
99
</div>
1010
}
1111
</div>

src/app/account/inbox-pictures/inbox-pictures.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AsyncPipe} from '@angular/common';
2-
import {Component, inject, OnInit} from '@angular/core';
2+
import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
33
import {ActivatedRoute} from '@angular/router';
44
import {PictureFields, PictureListOptions, PicturesList, PicturesRequest, PictureStatus} from '@grpc/spec.pb';
55
import {PicturesClient} from '@grpc/spec.pbsc';
@@ -14,6 +14,7 @@ import {ThumbnailComponent} from '../../thumbnail/thumbnail/thumbnail.component'
1414
import {ToastsService} from '../../toasts/toasts.service';
1515

1616
@Component({
17+
changeDetection: ChangeDetectionStrategy.OnPush,
1718
imports: [PaginatorComponent, AsyncPipe, ThumbnailComponent],
1819
selector: 'app-account-inbox-pictures',
1920
templateUrl: './inbox-pictures.component.html',

0 commit comments

Comments
 (0)