Skip to content

Commit

Permalink
Refactor gallery items
Browse files Browse the repository at this point in the history
  • Loading branch information
mczachurski committed Jan 1, 2025
1 parent 6b683e9 commit 2a3ad1d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
</div>
<div class="images-container">
<div class="flex-row">
<ng-container *ngFor="let status of statuses?.data; trackBy:trackByFn">
<a [routerLink]="['/statuses', status.id]" [ariaLabel]="'Status added by: ' + getMainStatus(status).user?.userName" (click)="onStatusClick()">
@if (getMainStatus(status).sensitive && !alwaysShowNSFW) {
<div @fadeIn class="blurhash">
<app-blurhash-image [horizontal]="true" [status]="status"></app-blurhash-image>
</div>
} @else {
<div @fadeIn class="image">
<app-image [horizontal]="true" [status]="status"></app-image>
</div>
}
</a>
</ng-container>
@if (statuses && statuses.data) {
@for (status of statuses.data; track status.id) {
<a [routerLink]="['/statuses', status.id]" [ariaLabel]="'Status added by: ' + getMainStatus(status).user?.userName" (click)="onStatusClick()">
@if (getMainStatus(status).sensitive && !alwaysShowNSFW) {
<div @fadeIn class="blurhash">
<app-blurhash-image [horizontal]="true" [status]="status"></app-blurhash-image>
</div>
} @else {
<div @fadeIn class="image">
<app-image [horizontal]="true" [status]="status"></app-image>
</div>
}
</a>
}
}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export class CategoryGalleryItemComponent extends ResponsiveComponent implements
this.statuses = await this.timelineService.category(this.category.name, undefined, undefined, undefined, this.numberOfVisibleStatuses, undefined);
}

trackByFn(_: number, item: Status): string {
return item.id;
}

getMainStatus(status: Status): Status {
return status.reblog ?? status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
</div>
<div class="images-container">
<div class="flex-row">
<ng-container *ngFor="let status of statuses?.data; trackBy:trackByFn">
<a [routerLink]="['/statuses', status.id]" [ariaLabel]="'Status added by: ' + getMainStatus(status).user?.userName" (click)="onStatusClick()">
@if (getMainStatus(status).sensitive && !alwaysShowNSFW) {
<div @fadeIn class="blurhash">
<app-blurhash-image [horizontal]="true" [status]="status"></app-blurhash-image>
</div>
} @else {
<div @fadeIn class="image">
<app-image [horizontal]="true" [status]="status"></app-image>
</div>
}
</a>
</ng-container>
@if (statuses && statuses.data) {
@for (status of statuses.data; track status.id) {
<a [routerLink]="['/statuses', status.id]" [ariaLabel]="'Status added by: ' + getMainStatus(status).user?.userName" (click)="onStatusClick()">
@if (getMainStatus(status).sensitive && !alwaysShowNSFW) {
<div @fadeIn class="blurhash">
<app-blurhash-image [horizontal]="true" [status]="status"></app-blurhash-image>
</div>
} @else {
<div @fadeIn class="image">
<app-image [horizontal]="true" [status]="status"></app-image>
</div>
}
</a>
}
}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export class HashtagGalleryItemComponent extends ResponsiveComponent implements
this.statuses = await this.timelineService.hashtag(this.hashtag.name, undefined, undefined, undefined, this.numberOfVisibleStatuses, undefined);
}

trackByFn(_: number, item: Status): string | undefined{
return item.id;
}

getMainStatus(status: Status): Status {
return status.reblog ?? status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
<app-user-card [user]="user"></app-user-card>
<div class="images-container">
<div class="flex-row">
<ng-container *ngFor="let status of statuses?.data; trackBy:trackByFn">
<a [routerLink]="['/statuses', status.id]" [ariaLabel]="'Status added by: ' + getMainStatus(status).user?.userName" (click)="onStatusClick()">
@if (getMainStatus(status).sensitive && !alwaysShowNSFW) {
<div @fadeIn class="blurhash">
<app-blurhash-image [horizontal]="true" [status]="status" [avatarVisible]="false"></app-blurhash-image>
</div>
} @else {
<div @fadeIn class="image">
<app-image [horizontal]="true" [status]="status" [avatarVisible]="false"></app-image>
</div>
}
</a>
</ng-container>
@if (statuses && statuses.data) {
@for (status of statuses.data; track status.id) {
<a [routerLink]="['/statuses', status.id]" [ariaLabel]="'Status added by: ' + getMainStatus(status).user?.userName" (click)="onStatusClick()">
@if (getMainStatus(status).sensitive && !alwaysShowNSFW) {
<div @fadeIn class="blurhash">
<app-blurhash-image [horizontal]="true" [status]="status" [avatarVisible]="false"></app-blurhash-image>
</div>
} @else {
<div @fadeIn class="image">
<app-image [horizontal]="true" [status]="status" [avatarVisible]="false"></app-image>
</div>
}
</a>
}
}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export class UsersGalleryItemComponent extends ResponsiveComponent implements On
}
}

trackByFn(_: number, item: Status): string | undefined{
return item.id;
}

getMainStatus(status: Status): Status {
return status.reblog ?? status;
}
Expand Down

0 comments on commit 2a3ad1d

Please sign in to comment.