fix notifications page on unauthed app #7226

Merged
jessopb merged 1 commit from fix-notificationsOnDesktopUnauthed into master 2021-10-06 16:13:37 +02:00
2 changed files with 23 additions and 20 deletions

View file

@ -2183,5 +2183,6 @@
"Creator": "Creator",
"From comments": "From comments",
"From search": "From search",
"Manage tags": "Manage tags",
"--end--": "--end--"
}

View file

@ -32,28 +32,30 @@ export default function NotificationSettingsPage(props: Props) {
const lbryIoParams = verificationToken ? { auth_token: verificationToken } : undefined;
React.useEffect(() => {
Lbryio.call('tag', 'list', lbryIoParams)
.then(setTags)
.catch((e) => {
setError(true);
});
if (isAuthenticated) {
Lbryio.call('tag', 'list', lbryIoParams)
.then(setTags)
.catch((e) => {
setError(true);
});
Lbryio.call('user_email', 'status', lbryIoParams)
.then((res) => {
const enabledEmails =
res.emails &&
Object.keys(res.emails).reduce((acc, email) => {
const isEnabled = res.emails[email];
return [...acc, { email, isEnabled }];
}, []);
Lbryio.call('user_email', 'status', lbryIoParams)
.then((res) => {
const enabledEmails =
res.emails &&
Object.keys(res.emails).reduce((acc, email) => {
const isEnabled = res.emails[email];
return [...acc, { email, isEnabled }];
}, []);
setTagMap(res.tags);
setEnabledEmails(enabledEmails);
})
.catch((e) => {
setError(true);
});
}, []);
setTagMap(res.tags);
setEnabledEmails(enabledEmails);
})
.catch((e) => {
setError(true);
});
}
}, [isAuthenticated]);
function handleChangeTag(name, newIsEnabled) {
const tagParams = newIsEnabled ? { add: name } : { remove: name };