Some fixes.

This commit is contained in:
Dessalines 2021-10-28 22:28:49 -04:00
parent 6db259efe1
commit 9e15b79622

View file

@ -110,7 +110,7 @@ export class Profile extends Component<any, ProfileState> {
} }
setupTippy(); setupTippy();
this.setPersonBlock() this.setPersonBlock();
} }
fetchUserData() { fetchUserData() {
@ -131,9 +131,11 @@ export class Profile extends Component<any, ProfileState> {
this.state.personRes.person_view.person.id this.state.personRes.person_view.person.id
); );
} }
setPersonBlock() { setPersonBlock() {
this.state.personBlocked = UserService.Instance.myUserInfo.person_blocks. this.state.personBlocked = UserService.Instance.myUserInfo.person_blocks
map(a => a.target.id).includes(this.state.personRes.person_view.person.id) .map(a => a.target.id)
.includes(this.state.personRes?.person_view.person.id);
} }
static getViewFromProps(view: string): PersonDetailsView { static getViewFromProps(view: string): PersonDetailsView {
@ -359,7 +361,7 @@ export class Profile extends Component<any, ProfileState> {
WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm)); WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
} }
} }
handleUnblockPerson(recipientId: number ) { handleUnblockPerson(recipientId: number) {
let blockUserForm: BlockPerson = { let blockUserForm: BlockPerson = {
person_id: recipientId, person_id: recipientId,
block: false, block: false,
@ -426,24 +428,23 @@ export class Profile extends Component<any, ProfileState> {
> >
{i18n.t("send_message")} {i18n.t("send_message")}
</Link> </Link>
{this.state.personBlocked ? {this.state.personBlocked ? (
( <button
<a
className={"d-flex align-self-start btn btn-secondary"} className={"d-flex align-self-start btn btn-secondary"}
onClick={linkEvent(pv.person.id, this.handleUnblockPerson)} onClick={linkEvent(
href="#" pv.person.id,
this.handleUnblockPerson
)}
> >
{i18n.t("unblock_user")} {i18n.t("unblock_user")}
</a> </button>
) : ) : (
( <button
<a
className={"d-flex align-self-start btn btn-secondary"} className={"d-flex align-self-start btn btn-secondary"}
onClick={linkEvent(pv.person.id, this.handleBlockPerson)} onClick={linkEvent(pv.person.id, this.handleBlockPerson)}
href="#"
> >
{i18n.t("block_user")} {i18n.t("block_user")}
</a> </button>
)} )}
</> </>
)} )}
@ -581,6 +582,7 @@ export class Profile extends Component<any, ProfileState> {
this.state.personRes = data; this.state.personRes = data;
console.log(data); console.log(data);
this.state.loading = false; this.state.loading = false;
this.setPersonBlock();
this.setState(this.state); this.setState(this.state);
restoreScrollPosition(this.context); restoreScrollPosition(this.context);
} else if (op == UserOperation.AddAdmin) { } else if (op == UserOperation.AddAdmin) {
@ -639,7 +641,7 @@ export class Profile extends Component<any, ProfileState> {
} else if (op == UserOperation.BlockPerson) { } else if (op == UserOperation.BlockPerson) {
let data = wsJsonToRes<BlockPersonResponse>(msg).data; let data = wsJsonToRes<BlockPersonResponse>(msg).data;
updatePersonBlock(data); updatePersonBlock(data);
this.setPersonBlock() this.setPersonBlock();
this.setState(this.state); this.setState(this.state);
} }
} }