Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change explore tab to collection tab #3243

Merged
merged 6 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class AppComponent {
'capture',
'profile',
'search',
'collection',
shc261392 marked this conversation as resolved.
Show resolved Hide resolved
'edit',
'capture-rebrand-add',
];
Expand Down
33 changes: 0 additions & 33 deletions src/app/features/home/capture-tab/capture-tab.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
<ion-segment-button [value]="captureTabSegments.VERIFIED">
<ion-label>{{ 'home.profileTab.verified' | transloco }}</ion-label>
</ion-segment-button>
<ion-segment-button [value]="captureTabSegments.COLLECTED">
<ion-label>{{ 'home.profileTab.collected' | transloco }}</ion-label>
</ion-segment-button>
<ion-segment-button [value]="captureTabSegments.DRAFT">
<ion-label>{{ 'home.profileTab.draft' | transloco }}</ion-label>
</ion-segment-button>
Expand All @@ -89,36 +86,6 @@
</div>
</div>

<div class="post-captures" *ngSwitchCase="captureTabSegments.COLLECTED">
shc261392 marked this conversation as resolved.
Show resolved Hide resolved
<mat-grid-list cols="2" gutterSize="16px">
<mat-grid-tile
class="capture-item"
*ngFor="
let postCapture of collectedTabItems$ | ngrxPush;
trackBy: trackPostCapture
"
[routerLink]="[
'details',
{ type: 'post-capture', id: postCapture.id }
]"
>
<ng-container *ngIf="postCapture.asset_file_mime_type as mimeType">
<ion-icon
*ngIf="mimeType | startsWith: 'video'"
name="videocam"
class="is-video"
></ion-icon>
</ng-container>
<ion-icon
*ngIf="postCapture.source_type === 'store'"
name="storefront"
class="is-from-store"
></ion-icon>
<ion-img [src]="postCapture.asset_file_thumbnail"></ion-img>
</mat-grid-tile>
</mat-grid-list>
</div>

<div *ngSwitchCase="captureTabSegments.DRAFT">
<div class="capture-container" *transloco="let t">
<mat-grid-list cols="2" gutterSize="16px">
Expand Down
27 changes: 2 additions & 25 deletions src/app/features/home/capture-tab/capture-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ import {
} from '../../../shared/capture-tab/capture-tab.service';
import { ConfirmAlert } from '../../../shared/confirm-alert/confirm-alert.service';
import { Database } from '../../../shared/database/database.service';
import {
DiaBackendAsset,
DiaBackendAssetRepository,
} from '../../../shared/dia-backend/asset/dia-backend-asset-repository.service';
import { DiaBackendAssetRepository } from '../../../shared/dia-backend/asset/dia-backend-asset-repository.service';
import { DiaBackendAsseRefreshingService } from '../../../shared/dia-backend/asset/refreshing/dia-backend-asset-refreshing.service';
import { DiaBackendAssetUploadingService } from '../../../shared/dia-backend/asset/uploading/dia-backend-asset-uploading.service';
import { DiaBackendAuthService } from '../../../shared/dia-backend/auth/dia-backend-auth.service';
Expand All @@ -60,7 +57,7 @@ export class CaptureTabComponent implements OnInit {
* Used in the HTML template to avoid hardcoded string values.
*/
readonly captureTabSegments = CaptureTabSegments;
segment: CaptureTabSegments = CaptureTabSegments.COLLECTED;
segment: CaptureTabSegments = CaptureTabSegments.VERIFIED;

readonly hasNewInbox$ = this.diaBackendTransactionRepository.inbox$.pipe(
catchError((err: unknown) => this.errorService.toastError$(err)),
Expand Down Expand Up @@ -117,19 +114,8 @@ export class CaptureTabComponent implements OnInit {

readonly capturedTabPageIndex$ = new BehaviorSubject<number>(0);

readonly collectedTabPageIndex$ = new BehaviorSubject<number>(0);

readonly draftTabPageIndex$ = new BehaviorSubject<number>(0);

readonly collectedTabItems$ = combineLatest([
this.postCaptures$,
shc261392 marked this conversation as resolved.
Show resolved Hide resolved
this.collectedTabPageIndex$,
]).pipe(
map(([items, page]) =>
items.slice(0, page * this.itemsPerPage + this.itemsPerPage)
)
);

readonly validatedCaptures$ = this.captures$.pipe(
map(proofs => proofs.filter(p => p.diaBackendAssetId !== undefined))
);
Expand Down Expand Up @@ -203,9 +189,6 @@ export class CaptureTabComponent implements OnInit {
case CaptureTabSegments.VERIFIED:
this.capturedTabPageIndex$.next(this.capturedTabPageIndex$.value + 1);
break;
case CaptureTabSegments.COLLECTED:
this.collectedTabPageIndex$.next(this.collectedTabPageIndex$.value + 1);
break;
case CaptureTabSegments.DRAFT:
this.draftTabPageIndex$.next(this.draftTabPageIndex$.value + 1);
}
Expand Down Expand Up @@ -341,11 +324,6 @@ export class CaptureTabComponent implements OnInit {
return getOldProof(item).hash;
}

// eslint-disable-next-line class-methods-use-this
trackPostCapture(_: number, item: DiaBackendAsset) {
return item.id;
}

async refreshCaptures(event: Event) {
(<CustomEvent>event).detail.complete();

Expand All @@ -355,7 +333,6 @@ export class CaptureTabComponent implements OnInit {
const confirmRefresh = await this.showRefreshAlert();
if (confirmRefresh) {
this.capturedTabPageIndex$.next(0);
this.collectedTabPageIndex$.next(0);
this.draftTabPageIndex$.next(0);

return this.dialog.open(PrefetchingDialogComponent, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"
>
<iframe
#exploreIframe
#collectionIframe
[src]="bubbleIframeUrlWithCachedJWTToken"
class="bubble-iframe"
></iframe>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { SharedTestingModule } from '../../../../shared/shared-testing.module';

import { ExploreTabComponent } from './explore-tab.component';
import { CollectionTabComponent } from './collection-tab.component';

describe('ExploreTabComponent', () => {
let component: ExploreTabComponent;
let fixture: ComponentFixture<ExploreTabComponent>;
describe('CollectionTabComponent', () => {
let component: CollectionTabComponent;
let fixture: ComponentFixture<CollectionTabComponent>;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ExploreTabComponent],
declarations: [CollectionTabComponent],
imports: [SharedTestingModule],
}).compileComponents();

fixture = TestBed.createComponent(ExploreTabComponent);
fixture = TestBed.createComponent(CollectionTabComponent);
component = fixture.componentInstance;
fixture.detectChanges();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,40 @@ import { NetworkService } from '../../../../shared/network/network.service';

@UntilDestroy()
@Component({
selector: 'app-explore-tab',
templateUrl: './explore-tab.component.html',
styleUrls: ['./explore-tab.component.scss'],
selector: 'app-collection-tab',
templateUrl: './collection-tab.component.html',
styleUrls: ['./collection-tab.component.scss'],
})
export class ExploreTabComponent {
export class CollectionTabComponent {
readonly bubbleIframeUrlWithCachedJWTToke$ = combineLatest([
this.diaBackendAuthService.cachedQueryJWTToken$,
this.iframeService.exploreTabRefreshRequested$,
this.iframeService.CollectionTabRefreshRequested$,
]).pipe(
map(([token, _]) => {
const url = `${BUBBLE_IFRAME_URL}/?token=${token.access}&refresh_token=${token.refresh}`;
const url = `${BUBBLE_IFRAME_URL}/collection?token=${token.access}&refresh_token=${token.refresh}`;
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
})
);

readonly networkConnected$ = this.networkService.connected$;

@ViewChild('exploreIframe') exploreIframe?: ElementRef<HTMLIFrameElement>;
@ViewChild('collectionIframe')
collectionIframe?: ElementRef<HTMLIFrameElement>;

constructor(
private readonly networkService: NetworkService,
private readonly diaBackendAuthService: DiaBackendAuthService,
private readonly iframeService: IframeService,
private readonly sanitizer: DomSanitizer
) {
iframeService.exploreTabIframeNavigateBack$
.pipe(
tap(_ => this.navigateBackExploreIframe()),
untilDestroyed(this)
)
.subscribe();
iframeService.CollectionTabIframeNavigateBack$.pipe(
tap(_ => this.navigateBackcollectionIframe()),
untilDestroyed(this)
).subscribe();
}

navigateBackExploreIframe() {
this.exploreIframe?.nativeElement.contentWindow?.postMessage(
navigateBackcollectionIframe() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigateBackCollectionIframe

this.collectionIframe?.nativeElement.contentWindow?.postMessage(
IonicToBubblePostMessage.ANDROID_BACK_BUTTON,
BUBBLE_IFRAME_URL
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/home/home.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SharedModule } from '../../shared/shared.module';
import { CaptureItemComponent } from './capture-tab/capture-item/capture-item.component';
import { CaptureTabComponent } from './capture-tab/capture-tab.component';
import { UploadingBarComponent } from './capture-tab/uploading-bar/uploading-bar.component';
import { ExploreTabComponent } from './explore-tab/explore-tab/explore-tab.component';
import { CollectionTabComponent } from './collection-tab/collection-tab/collection-tab.component';
import { HomePageRoutingModule } from './home-routing.module';
import { HomePage } from './home.page';
import { UpdateAppDialogComponent } from './in-app-updates/update-app-dialog/update-app-dialog.component';
Expand All @@ -15,7 +15,7 @@ import { PostCaptureTabComponent } from './post-capture-tab/post-capture-tab.com
declarations: [
HomePage,
CaptureTabComponent,
ExploreTabComponent,
CollectionTabComponent,
PostCaptureTabComponent,
PrefetchingDialogComponent,
UpdateAppDialogComponent,
Expand Down
6 changes: 3 additions & 3 deletions src/app/features/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<button mat-icon-button (click)="navigateToExploreTab()">
<button mat-icon-button (click)="navigateToCollectionTab()">
<mat-icon
svgIcon="search"
svgIcon="collection"
class="tab-action-button-icon"
joyrideStep="highlightHomeTab"
title="Home Tab"
text="View created captures"
></mat-icon>
</button>
</ng-template>
<app-explore-tab></app-explore-tab>
<app-collection-tab></app-collection-tab>
</mat-tab>
</mat-tab-group>
</mat-sidenav-content>
Expand Down
33 changes: 18 additions & 15 deletions src/app/features/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import { PrefetchingDialogComponent } from './onboarding/prefetching-dialog/pref
export class HomePage {
readonly initialTabIndex = 0;
private readonly afterCaptureTabIndex = 0;
private readonly exploreTabIndex = 2;
private readonly CollectionTabIndex = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the naming rule - start with lowercase.

selectedTabIndex = this.initialTabIndex;

readonly username$ = this.diaBackendAuthService.username$;
Expand Down Expand Up @@ -305,11 +305,11 @@ export class HomePage {
overrideAndroidBackButtonBehavior() {
this.androidBackButtonService
.overrideAndroidBackButtonBehavior$(() => {
const shouldNavigateBackExploreTabIframe =
this.selectedTabIndex === this.exploreTabIndex &&
const shouldNavigateBackCollectionTabIframe =
this.selectedTabIndex === this.CollectionTabIndex &&
this.router.url === '/home';
if (shouldNavigateBackExploreTabIframe) {
this.iframeService.navigateBackExploreTabIframe();
if (shouldNavigateBackCollectionTabIframe) {
this.iframeService.navigateBackCollectionTabIframe();
} else {
this.navController.back();
}
Expand Down Expand Up @@ -424,32 +424,35 @@ export class HomePage {
}

// eslint-disable-next-line class-methods-use-this
async navigateToExploreTab() {
if (this.selectedTabIndex === this.exploreTabIndex) {
async navigateToCollectionTab() {
if (this.selectedTabIndex === this.CollectionTabIndex) {
// window.location.reload();
this.iframeService.refreshExploreTabIframe();
this.iframeService.refreshCollectionTabIframe();
}
const didExplain = await this.onboardingService.didExplainExploreTab();
/* TODO: re-enable or remove the popup.
Hide the popup in current version as a temporary decision.
const didExplain = await this.onboardingService.didExplainCollectionTab();
if (didExplain === false) {
await new Promise(resolve => {
setTimeout(resolve, OnboardingService.ONBOARDING_POP_UP_DELAY);
});
this.showExplainExploreTabPopUpDialog();
this.onboardingService.setDidExplainExploreTab(true);
this.showExplainCollectionTabPopUpDialog();
this.onboardingService.setDidExplainCollectionTab(true);
}
*/
}

private showExplainExploreTabPopUpDialog() {
private showExplainCollectionTabPopUpDialog() {
const panelClass = 'onboarding-pop-up-dialog';
const data: OnboardingPopUpDialogData = {
title: this.translocoService.translate(
'onboarding.explainExploreTabPopUp.title'
'onboarding.explainCollectionTabPopUp.title'
),
content: this.translocoService.translate(
'onboarding.explainExploreTabPopUp.content'
'onboarding.explainCollectionTabPopUp.content'
),
close: this.translocoService.translate(
'onboarding.explainExploreTabPopUp.close'
'onboarding.explainCollectionTabPopUp.close'
),
};
return this.dialog.open(OnboardingPopUpDialogComponent, {
Expand Down
1 change: 0 additions & 1 deletion src/app/shared/capture-tab/capture-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ export class CaptureTabService {

export enum CaptureTabSegments {
VERIFIED = 'VERIFIED',
COLLECTED = 'COLLECTED',
DRAFT = 'DRAFT',
}
19 changes: 9 additions & 10 deletions src/app/shared/iframe/iframe.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ export class IframeService {

private readonly preferences = this.preferenceManager.getPreferences(this.id);

readonly exploreTabRefreshRequested$ = new BehaviorSubject(new Date());
readonly CollectionTabRefreshRequested$ = new BehaviorSubject(new Date());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the naming rule - start with lowercase.


private readonly _exploreTabIframeNavigateBack$ = new ReplaySubject<boolean>(
1
);
private readonly _CollectionTabIframeNavigateBack$ =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the naming rule - start with lowercase.

new ReplaySubject<boolean>(1);

readonly exploreTabIframeNavigateBack$ =
this._exploreTabIframeNavigateBack$.asObservable();
readonly CollectionTabIframeNavigateBack$ =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the naming rule - start with lowercase.

this._CollectionTabIframeNavigateBack$.asObservable();

readonly detailsPageIframeReloadRequested$ = this.preferences.getNumber$(
PrefKeys.DETAILS_PAGE_RELOAD_REQUESTED_TIMESTAMP,
Expand All @@ -26,12 +25,12 @@ export class IframeService {

constructor(private readonly preferenceManager: PreferenceManager) {}

refreshExploreTabIframe() {
this.exploreTabRefreshRequested$.next(new Date());
refreshCollectionTabIframe() {
this.CollectionTabRefreshRequested$.next(new Date());
}

navigateBackExploreTabIframe() {
this._exploreTabIframeNavigateBack$.next(true);
navigateBackCollectionTabIframe() {
this._CollectionTabIframeNavigateBack$.next(true);
}

refreshDetailsPageIframe() {
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/onboarding/onboarding.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ export class OnboardingService {
);
}

async didExplainExploreTab() {
async didExplainCollectionTab() {
return this.preferences.getBoolean(PrefKeys.DID_EXPLAIN_EXPLORE_TAB, false);
}

async setDidExplainExploreTab(value: boolean) {
async setDidExplainCollectionTab(value: boolean) {
return this.preferences.setBoolean(PrefKeys.DID_EXPLAIN_EXPLORE_TAB, value);
}
}
Expand Down
Loading
Loading