Skip to content

Commit

Permalink
iris account settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalmi committed Aug 22, 2023
1 parent b88f136 commit e8744ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/js/views/settings/irisaccount/ActiveAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Key from '@/nostr/Key.ts';
import SocialNetwork from '@/nostr/SocialNetwork.ts';
import AccountName from '@/views/settings/irisaccount/AccountName.tsx';

export default function ActiveAccount({ name }) {
const setAsPrimary = () => {
export default function ActiveAccount({ name, setAsPrimary }) {
const onClick = () => {
const newNip = name + '@iris.to';
const timeout = setTimeout(() => {
SocialNetwork.setMetadata({ nip05: newNip });
Expand All @@ -14,6 +14,7 @@ export default function ActiveAccount({ name }) {
if (p.nip05 !== newNip) {
p.nip05 = newNip;
SocialNetwork.setMetadata(p);
setAsPrimary();
}
}
});
Expand All @@ -26,7 +27,7 @@ export default function ActiveAccount({ name }) {
<AccountName name={name} />
</div>
<p>
<button className="btn btn-sm btn-primary" onClick={setAsPrimary}>
<button className="btn btn-sm btn-primary" onClick={onClick}>
Set as primary Nostr address (nip05)
</button>
</p>
Expand Down
8 changes: 7 additions & 1 deletion src/js/views/settings/irisaccount/IrisAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare global {
}
}

// TODO split into smaller components
export default class IrisAccount extends Component {
state = {
irisToActive: false,
Expand All @@ -36,7 +37,12 @@ export default class IrisAccount extends Component {
const username = this.state.profile.nip05.split('@')[0];
view = <AccountName name={username} />;
} else if (this.state.existing && this.state.existing.confirmed) {
view = <ActiveAccount name={this.state.existing.name} />;
view = (
<ActiveAccount
name={this.state.existing.name}
setAsPrimary={() => this.setState({ irisToActive: true })}
/>
);
} else if (this.state.existing) {
view = (
<ReservedAccount
Expand Down

0 comments on commit e8744ca

Please sign in to comment.