Skip to content

Commit

Permalink
feat(features/home): add showcase shared link
Browse files Browse the repository at this point in the history
Add a shared link to the Showcase page on the Home page.
  • Loading branch information
olgahaha committed Oct 29, 2024
1 parent 8b04bd0 commit 31dffc8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
13 changes: 12 additions & 1 deletion src/app/features/home/capture-tab/capture-tab.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
<mat-icon>more_horiz</mat-icon>
</button>
<span class="toolbar-spacer"></span>
<button routerLink="activities" mat-mini-fab class="custom-fab-button">
<button
(click)="shareShowcaseLink()"
mat-mini-fab
class="custom-fab-button"
>
<mat-icon svgIcon="capture-rebrand-share"></mat-icon>
</button>
<button
routerLink="activities"
mat-mini-fab
class="custom-fab-button margin-left-8"
>
<mat-icon [title]="'userGuide.activities' | transloco">
history
</mat-icon>
Expand Down
22 changes: 17 additions & 5 deletions src/app/features/home/capture-tab/capture-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
concatMapTo,
map,
startWith,
switchMap,
tap,
} from 'rxjs/operators';
import { BlockingActionService } from '../../../shared/blocking-action/blocking-action.service';
Expand All @@ -23,7 +24,6 @@ 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 { DiaBackendAssetRepository } from '../../../shared/dia-backend/asset/dia-backend-asset-repository.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';
import { DiaBackendTransactionRepository } from '../../../shared/dia-backend/transaction/dia-backend-transaction-repository.service';
Expand All @@ -34,9 +34,10 @@ import { PreferenceManager } from '../../../shared/preference-manager/preference
import { getOldProof } from '../../../shared/repositories/proof/old-proof-adapter';
import { Proof } from '../../../shared/repositories/proof/proof';
import { ProofRepository } from '../../../shared/repositories/proof/proof-repository.service';
import { ShareService } from '../../../shared/share/share.service';
import { browserToolbarColor } from '../../../utils/constants';
import { reloadApp } from '../../../utils/miscellaneous';
import { getFaqUrl } from '../../../utils/url';
import { getFaqUrl, getShowcaseUrl } from '../../../utils/url';
import { PrefetchingDialogComponent } from '../onboarding/prefetching-dialog/prefetching-dialog.component';

@UntilDestroy({ checkProperties: true })
Expand Down Expand Up @@ -142,20 +143,20 @@ export class CaptureTabComponent implements OnInit {
private readonly changeDetectorRef: ChangeDetectorRef,
private readonly proofRepository: ProofRepository,
private readonly diaBackendAuthService: DiaBackendAuthService,
private readonly diaBackendAssetRepository: DiaBackendAssetRepository,
private readonly diaBackendTransactionRepository: DiaBackendTransactionRepository,
private readonly networkService: NetworkService,
private readonly translocoService: TranslocoService,
private readonly errorService: ErrorService,
private readonly blockingActionService: BlockingActionService,
private readonly captureTabService: CaptureTabService,
private readonly uploadService: DiaBackendAssetUploadingService
private readonly uploadService: DiaBackendAssetUploadingService,
private readonly shareService: ShareService
) {
this.uploadService.pendingTasks$
.pipe(untilDestroyed(this))
.subscribe(value => (this.pendingUploadTasks = value));
this.diaBackendAuthService
.readProfile$()
.syncUser$()
.pipe(untilDestroyed(this))
.subscribe();
}
Expand Down Expand Up @@ -232,6 +233,17 @@ export class CaptureTabComponent implements OnInit {
.then(sheet => sheet.present());
}

shareShowcaseLink() {
defer(() => this.username$)
.pipe(
switchMap(username =>
this.shareService.shareShowcasePage(getShowcaseUrl(username))
),
untilDestroyed(this)
)
.subscribe();
}

logout() {
const action$ = defer(() => this.mediaStore.clear()).pipe(
concatMapTo(defer(() => this.database.clear())),
Expand Down
17 changes: 0 additions & 17 deletions src/app/shared/dia-backend/auth/dia-backend-auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,6 @@ export class DiaBackendAuthService {
);
}

readProfile$() {
return defer(() => this.getAuthHeaders()).pipe(
concatMap(headers =>
this.httpClient.get<ReadProfileResponse>(
`${BASE_URL}/auth/users/profile/`,
{
headers,
}
)
),
tap(response => {
this.profile$.next(response);
this.setDisplayName(response.display_name);
})
);
}

createUser$(
username: string,
email: string,
Expand Down
4 changes: 4 additions & 0 deletions src/app/shared/share/share.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ export class ShareService {

return Share.share({ text: text + '\n' + urlToDownloadApp });
}

async shareShowcasePage(url: string) {

Check failure on line 61 in src/app/shared/share/share.service.ts

View workflow job for this annotation

GitHub Actions / lint

Expected 'this' to be used by class async method 'shareShowcasePage'

Check warning on line 61 in src/app/shared/share/share.service.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/app/shared/share/share.service.ts#L61

Expected 'this' to be used by class async method 'shareShowcasePage'.
return Share.share({ text: url });
}
}
4 changes: 4 additions & 0 deletions src/app/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ export function getAppDownloadLink(isPlatform: (platformName: any) => boolean) {
export function getFaqUrl() {
return 'https://docs.captureapp.xyz/faq';
}

export function getShowcaseUrl(username: string) {
return `https://dashboard.captureapp.xyz/showcase/${username}`;
}

0 comments on commit 31dffc8

Please sign in to comment.