Skip to content

Commit

Permalink
likhith/fixed the toggle issue in privacy setting (#5007)
Browse files Browse the repository at this point in the history
* refactored code to resolve the toggle issue

* Trigger Build
  • Loading branch information
likhith-deriv committed Apr 27, 2022
1 parent fffb2f8 commit 37759fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 0 additions & 4 deletions packages/p2p/src/stores/general-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ export default class GeneralStore extends BaseStore {
}

const { sendbird_store } = this.root_store;

this.ws_subscriptions = {
advertiser_subscription: subscribeWS(
{
Expand Down Expand Up @@ -439,17 +438,14 @@ export default class GeneralStore extends BaseStore {
@action.bound
updateAdvertiserInfo(response) {
const { p2p_advertiser_info } = response;

if (!response.error) {
this.setAdvertiserId(p2p_advertiser_info.id);
this.setIsAdvertiser(!!p2p_advertiser_info.is_approved);
this.setIsListed(!!p2p_advertiser_info.is_listed);
this.setNickname(p2p_advertiser_info.name);
this.setUserBlockedUntil(p2p_advertiser_info.blocked_until);
this.setShouldShowRealName(!!p2p_advertiser_info.show_name);
} else {
this.ws_subscriptions.advertiser_subscription.unsubscribe();

if (response.error.code === 'RestrictedCountry') {
this.setIsRestricted(true);
} else if (response.error.code === 'AdvertiserNotFound') {
Expand Down
9 changes: 6 additions & 3 deletions packages/p2p/src/stores/my-profile-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default class MyProfileStore extends BaseStore {
this.setBalanceAvailable(p2p_advertiser_info.balance_available);
this.setContactInfo(p2p_advertiser_info.contact_info);
this.setDefaultAdvertDescription(p2p_advertiser_info.default_advert_description);
this.root_store.general_store.setShouldShowRealName(!!p2p_advertiser_info.show_name);
} else if (response.error.code === 'PermissionDenied') {
this.root_store.general_store.setIsBlocked(true);
} else {
Expand Down Expand Up @@ -309,14 +310,16 @@ export default class MyProfileStore extends BaseStore {
}
@action.bound
handleToggle() {
this.root_store.general_store.setShouldShowRealName(!this.root_store?.general_store?.should_show_real_name);
requestWS({
p2p_advertiser_update: 1,
show_name: this.root_store?.general_store?.should_show_real_name ? 0 : 1,
show_name: this.root_store?.general_store?.should_show_real_name ? 1 : 0,
}).then(response => {
if (response.error) {
this.setFormError(response.error.message);
} else {
this.root_store.general_store.setShouldShowRealName(true);
this.root_store.general_store.setShouldShowRealName(
!this.root_store?.general_store?.should_show_real_name
);
}
});
}
Expand Down

0 comments on commit 37759fd

Please sign in to comment.