Skip to content

Commit

Permalink
Issues Fixed for diff Channel Features like edit channel or add delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-01k committed Feb 27, 2024
1 parent c18f32f commit aee39ca
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 42 deletions.
25 changes: 13 additions & 12 deletions src/components/ChannelDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function ChannelDetails({ isChannelExpired, setIsChannelExpired,
const { userPushSDKInstance } = useSelector((state) => {
return state.user;
});
const {handleConnectWallet} = useContext(AppContext);
const { handleConnectWallet } = useContext(AppContext);
const { CHANNEL_ACTIVE_STATE, CHANNNEL_DEACTIVATED_STATE } = useSelector((state) => state.channels);
const { processingState } = useSelector((state) => state.channelCreation);
const [verifyingChannel, setVerifyingChannel] = React.useState([]);
Expand Down Expand Up @@ -77,10 +77,9 @@ export default function ChannelDetails({ isChannelExpired, setIsChannelExpired,

const addDelegateToast = useToast();

const handleDelegateModal = () => {
const handleDelegateModal = async () => {
if (!userPushSDKInstance.signer) {
handleConnectWallet();
return;
await handleConnectWallet();
}
showAddDelegateModal();
}
Expand Down Expand Up @@ -156,17 +155,19 @@ export default function ChannelDetails({ isChannelExpired, setIsChannelExpired,
}
}, [account]);

const removeDelegate = (walletAddress) => {
return userPushSDKInstance.channel.delegate.remove(convertAddressToAddrCaip(walletAddress, chainId));
const removeDelegate = async (walletAddress) => {
let userPushInstance = userPushSDKInstance;
if (!userPushInstance.signer) {
userPushInstance = await handleConnectWallet();
if (!userPushInstance) {
return;
}
}

return userPushInstance.channel.delegate.remove(convertAddressToAddrCaip(walletAddress, chainId));
};

const navigateToNotifSettings = () => {

if (!userPushSDKInstance.signer) {
handleConnectWallet();
return;
}

navigate(APP_PATHS.ChannelSettings);
};

Expand Down
8 changes: 4 additions & 4 deletions src/components/ChannelSettingsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ function ChannelSettings({ DropdownRef, isDropdownOpen, closeDropdown }: Channel
const userSignerToast = useToast();
const toggleChannelActivationState = () => {
if (isChannelBlocked) return;
if (!userPushSDKInstance.signer) {
handleConnectWallet();
return;
}
// if (!userPushSDKInstance.signer) {
// handleConnectWallet();
// return;
// }
if (isChannelDeactivated) {
showReactivateChannelModal();
} else {
Expand Down
49 changes: 27 additions & 22 deletions src/components/channel/NotificationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function NotificationSettings() {
const [settingToEdit, setSettingToEdit] = React.useState<ChannelSetting>(undefined);
const [isLoading, setIsLoading] = React.useState(false);
const [isLoadingSettings, setIsLoadingSettings] = React.useState(true);
const {handleConnectWallet} = useContext(AppContext);
const { handleConnectWallet } = useContext(AppContext);

const { userPushSDKInstance } = useSelector((state: any) => {
return state.user;
Expand Down Expand Up @@ -133,12 +133,17 @@ function NotificationSettings() {
const saveSettings = async () => {
try {

if (!userPushSDKInstance.signer) {
handleConnectWallet();
return;
setIsLoading(true);

let userPushInstance = userPushSDKInstance;
if (!userPushInstance.signer) {
userPushInstance = await handleConnectWallet();
if (!userPushInstance) {
setIsLoading(false);
return;
}
}

setIsLoading(true);

notificationToast.showLoaderToast({ loaderMessage: 'Waiting for Confirmation...' });
const settingData: NotificationSetting[] = settings.map((setting) => {
Expand All @@ -153,14 +158,14 @@ function NotificationSettings() {
console.info(
{
type: setting.type,
description: setting.description,
default: setting.default,
data: {
lower: setting.lowerLimit,
upper: setting.upperLimit,
ticker: setting.ticker,
enabled: setting.enabled,
},
description: setting.description,
default: setting.default,
data: {
lower: setting.lowerLimit,
upper: setting.upperLimit,
ticker: setting.ticker,
enabled: setting.enabled,
},
}
)
return {
Expand All @@ -178,14 +183,14 @@ function NotificationSettings() {
console.info(
{
type: setting.type,
description: setting.description,
default: setting.default,
data: {
lower: setting.lowerLimit,
upper: setting.upperLimit,
ticker: setting.ticker,
enabled: setting.enabled,
},
description: setting.description,
default: setting.default,
data: {
lower: setting.lowerLimit,
upper: setting.upperLimit,
ticker: setting.ticker,
enabled: setting.enabled,
},
}
)
return {
Expand All @@ -202,7 +207,7 @@ function NotificationSettings() {
}
});
console.info(settingData);
await userPushSDKInstance.channel.setting(settingData);
await userPushInstance.channel.setting(settingData);

dispatch(updateChannelSetting({ channelAddress, settings }));
setIsLoading(false);
Expand Down
8 changes: 4 additions & 4 deletions src/modules/channelDashboard/ChannelOwnerDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ const ChannelOwnerDashboard = () => {
}

const showEditChannel = () => {
if (!userPushSDKInstance.signer) {
handleConnectWallet();
return;
}
// if (!userPushSDKInstance.signer) {
// handleConnectWallet();
// return;
// }
setEditChannel(true);
}

Expand Down

0 comments on commit aee39ca

Please sign in to comment.