Skip to content

Commit

Permalink
Fix an issue with FAQ Items
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreb committed Dec 22, 2024
1 parent e2be056 commit ef8204d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions src/app/pages/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { BreadcrumbComponent } from '../../components/breadcrumb.component';
import { RelayService } from '../../services/relay.service';
import { FaqItem, RelayService } from '../../services/relay.service';
import { SigningDialogComponent } from '../../components/signing-dialog.component';
import NDK, {
calculateRelaySetFromEvent,
Expand All @@ -29,11 +29,11 @@ interface ProjectContent {
lastUpdated?: number;
}

interface FaqItem {
id: string;
question: string;
answer: string;
}
// interface FaqItem {
// id: string;
// question: string;
// answer: string;
// }

interface ProjectMembers {
pubkeys: string[];
Expand Down Expand Up @@ -674,7 +674,7 @@ export class ProfileComponent implements OnInit {
npub: pubkey,
relayUrls: this.relayService.relayUrls,
});
} else {
} else {
this.user = new NDKUser({
pubkey: pubkey,
relayUrls: this.relayService.relayUrls,
Expand Down Expand Up @@ -721,11 +721,15 @@ export class ProfileComponent implements OnInit {
// Load FAQ
const faqData = await this.relayService.loadFaqContent(pubkey);
if (faqData && Array.isArray(faqData)) {
this.faqItems = faqData.map((item) => ({
...item,
id: crypto.randomUUID(),
}));
this.faqItems = faqData;
}
// if (faqData && Array.isArray(faqData)) {
// this.faqItems = faqData.map((item) => ({
// id: item.id || crypto.randomUUID(), // Only generate new ID if one doesn't exist
// question: item.question,
// answer: item.answer
// }));
// }

// Load members
const membersData = await this.relayService.loadMembers(pubkey);
Expand Down Expand Up @@ -780,7 +784,7 @@ export class ProfileComponent implements OnInit {

addFaqItem() {
this.faqItems.push({
id: crypto.randomUUID(),
id: crypto.randomUUID(), // Generate new ID only for new items
question: '',
answer: '',
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/relay.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface ProjectMembers {
}

export interface FaqItem {
id?: number;
id: string;
question: string;
answer: string;
}
Expand Down

0 comments on commit ef8204d

Please sign in to comment.