Fix recsys submission when user is null (#54)

## Issue
44 tor browser crash related to recsys?

## Reproduce the exact error
Block the request for `me|new` in dev tools

## Fix
The code was trying to destructure a null object.

The existing code seems to indicate that null ID is expected (it uses null as fallback), so this change shouldn't impact recsys results (I didn't check the recsys docs to confirm).
This commit is contained in:
infinite-persistence 2021-10-13 00:10:35 +08:00 committed by GitHub
parent a168dbcc01
commit 6f3c43c95f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -97,6 +97,7 @@
"About --[tab title in Channel Page]--": "About", "About --[tab title in Channel Page]--": "About",
"About --[link title in Sidebar or Footer]--": "About", "About --[link title in Sidebar or Footer]--": "About",
"Community Guidelines": "Community Guidelines", "Community Guidelines": "Community Guidelines",
"FAQ and Support": "FAQ and Support",
"Share Channel": "Share Channel", "Share Channel": "Share Channel",
"Go to page:": "Go to page:", "Go to page:": "Go to page:",
"Enter a URL for your thumbnail.": "Enter a URL for your thumbnail.", "Enter a URL for your thumbnail.": "Enter a URL for your thumbnail.",

View file

@ -92,7 +92,8 @@ const recsys = {
createRecsysEntry: function (claimId, parentUuid) { createRecsysEntry: function (claimId, parentUuid) {
if (window && window.store && claimId) { if (window && window.store && claimId) {
const state = window.store.getState(); const state = window.store.getState();
const { id: userId } = selectUser(state); const user = selectUser(state);
const userId = user ? user.id : null;
if (parentUuid) { if (parentUuid) {
// Make a stub entry that will be filled out on page load // Make a stub entry that will be filled out on page load
recsys.entries[claimId] = { recsys.entries[claimId] = {