Skip to content

Commit

Permalink
PER-9503: Remove Facebook integration from App Workspace
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
crisnicandrei committed Mar 26, 2024
1 parent f371a81 commit b3a6dde
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 62 deletions.
10 changes: 1 addition & 9 deletions src/app/apps/components/connector/connector.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
<div class="name">
{{ connector.type | prConstants }}
</div>
<div class="blurb" [ngSwitch]="connector.type">
<ng-container *ngSwitchCase="'type.connector.familysearch'"
>Connect your family memories</ng-container
>
</div>
<div class="blurb">Connect your family memories</div>
</div>
</div>
<div class="connector-actions">
Expand All @@ -34,7 +30,6 @@
[hidden]="!folder"
(click)="goToFolder()"
[disabled]="waiting"
*ngIf="connector.type.includes('familysearch')"
>
View Memories
</button>
Expand All @@ -44,7 +39,6 @@
[hidden]="!connected"
(click)="startFamilysearchTreeImport()"
[disabled]="waiting"
*ngIf="connector.type.includes('familysearch')"
>
Import family tree
</button>
Expand All @@ -54,7 +48,6 @@
[hidden]="!(connected && connector.ConnectorFamilysearchVO)"
(click)="familysearchUploadRequest()"
[disabled]="waiting"
*ngIf="connector.type.includes('familysearch')"
>
Upload to FamilySearch
</button>
Expand All @@ -64,7 +57,6 @@
[hidden]="!(connected && connector.ConnectorFamilysearchVO)"
(click)="familysearchDownloadRequest()"
[disabled]="waiting"
*ngIf="connector.type.includes('familysearch')"
>
Download from FamilySearch
</button>
Expand Down
72 changes: 19 additions & 53 deletions src/app/apps/components/connector/connector.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,15 @@ export class ConnectorComponent implements OnInit {
this.connectorName = this.prConstants.translate(this.connector.type);
this.setStatus();

switch (type) {
case 'familysearch':
this.connectText = 'Sign In with FamilySearch';
break;
}
this.connectText = 'Sign In with FamilySearch';
}

setStatus() {
this.connected = this.connector.status === 'status.connector.connected';
}

getConnectorClass(type: ConnectorType) {
switch (type) {
case 'type.connector.familysearch':
return 'connector-familysearch';
}
return 'connector-familysearch';
}

async familysearchUploadRequest() {
Expand Down Expand Up @@ -227,20 +220,16 @@ export class ConnectorComponent implements OnInit {
archives for each of those persons. You'll find those
memories saved in the apps section of those person archives.</p>
`;
switch (this.connector.type) {
case 'type.connector.familysearch':
if (!this.connected) {
template = `
if (!this.connected) {
template = `
<p>Connect to your FamilySearch account with the <strong>Sign In with FamilySearch</strong> option.</p>
${familySearchHelp}
`;
} else {
template = `
} else {
template = `
<p>Create separate, private Permanent Archives from your existing FamilySearch family tree data using the <strong>Import Family Tree</strong> option.</p>
${familySearchHelp}
`;
}
break;
}

const done: string = 'Learn More';
Expand All @@ -255,12 +244,10 @@ export class ConnectorComponent implements OnInit {
template
)
.then((val) => {
if (this.isFamilySearch()) {
window.open(
'https://desk.zoho.com/portal/permanent/en/kb/articles/import-persons-memories-familysearch',
'_blank'
);
}
window.open(
'https://desk.zoho.com/portal/permanent/en/kb/articles/import-persons-memories-familysearch',
'_blank'
);
})
.catch(() => {
// Do nothing on "Cancel" press, but still catch the promise rejection.
Expand All @@ -285,24 +272,16 @@ export class ConnectorComponent implements OnInit {
return '';
}

switch (this.connector.type) {
case 'type.connector.familysearch':
return 'View imported memories and add new memories to upload';
}
return 'View imported memories and add new memories to upload';
}

connect() {
let connectRequest: Observable<any>;
const archive = this.account.getArchive();

this.waiting = true;

switch (this.connector.type) {
case 'type.connector.familysearch':
this.storage.local.set('familysearchConnect', true);
connectRequest = this.api.connector.familysearchConnect(archive);
break;
}
this.storage.local.set('familysearchConnect', true);
const connectRequest = this.api.connector.familysearchConnect(archive);

if (connectRequest) {
return connectRequest
Expand All @@ -327,16 +306,12 @@ export class ConnectorComponent implements OnInit {
}

disconnect() {
let disconnectRequest: Observable<any>;
const archive = this.account.getArchive();

this.waiting = true;

switch (this.connector.type) {
case 'type.connector.familysearch':
disconnectRequest = this.api.connector.familysearchDisconnect(archive);
break;
}
const disconnectRequest =
this.api.connector.familysearchDisconnect(archive);

if (disconnectRequest) {
return disconnectRequest
Expand All @@ -362,19 +337,14 @@ export class ConnectorComponent implements OnInit {
}

async authorize(code: string) {
let connectRequest: Promise<ConnectorResponse>;
const archive = this.account.getArchive();

this.waiting = true;

switch (this.connector.type) {
case 'type.connector.familysearch':
connectRequest = this.api.connector.familysearchAuthorize(
archive,
code
);
break;
}
const connectRequest = this.api.connector.familysearchAuthorize(
archive,
code
);

if (connectRequest) {
try {
Expand Down Expand Up @@ -408,8 +378,4 @@ export class ConnectorComponent implements OnInit {
this.waiting = false;
}
}

private isFamilySearch(): boolean {
return this.connector.type === 'type.connector.familysearch';
}
}

0 comments on commit b3a6dde

Please sign in to comment.