allow claims to be updated and abandoned #595

Merged
daovist merged 46 commits from update-claims into master 2018-11-09 16:50:34 +01:00
daovist commented 2018-09-06 17:20:56 +02:00 (Migrated from github.com)
#482 #554
skhameneh (Migrated from github.com) requested changes 2018-09-24 19:54:11 +02:00
skhameneh (Migrated from github.com) left a comment

Nothing too major

Nothing too major
skhameneh (Migrated from github.com) commented 2018-09-24 19:40:21 +02:00

You've repeated this code a few times for getting the asset, I'd suggest creating a util method

You've repeated this code a few times for getting the `asset`, I'd suggest creating a util method
skhameneh (Migrated from github.com) commented 2018-09-24 19:41:04 +02:00

See above comment about adding a util

See above comment about adding a util
skhameneh (Migrated from github.com) commented 2018-09-24 19:43:43 +02:00

Please use spread operators to clean this up.

e.g.:

{
  ...state,
  assetList: newAssetList,
  channelList: {
    ...state.channelList,
    [channelId]: {}
  }
}
Please use spread operators to clean this up. e.g.: ``` { ...state, assetList: newAssetList, channelList: { ...state.channelList, [channelId]: {} } } ```
skhameneh (Migrated from github.com) commented 2018-09-24 19:44:05 +02:00

Same as above, use spread operators

Same as above, use spread operators
skhameneh (Migrated from github.com) commented 2018-09-24 19:44:39 +02:00

Should use consistent formatting (I know, the existing code is inconsistent)

Should use consistent formatting (I know, the existing code is inconsistent)
@ -0,0 +9,4 @@
const { claimData, history } = action.data;
const { claimId } = claimData;
const confirm = window.confirm('Are you sure you want to abandon this claim? This action cannot be undone.');
skhameneh (Migrated from github.com) commented 2018-09-24 19:46:17 +02:00

This works for now, but we should have some common prompt to match Spee.ch.

This works for now, but we should have some common prompt to match Spee.ch.
skhameneh (Migrated from github.com) commented 2018-09-24 19:47:56 +02:00

This logic exists in both conditions, can you move it out?

This logic exists in both conditions, can you move it out?
skhameneh (Migrated from github.com) commented 2018-09-24 19:48:28 +02:00

Can move this out as publishChannel = yield call(makePublishRequestChannel, publishFormData, isUpdate);

Can move this out as `publishChannel = yield call(makePublishRequestChannel, publishFormData, isUpdate);`
skhameneh (Migrated from github.com) commented 2018-09-24 19:53:31 +02:00

You have this validation in more than one place, please combine

You have this validation in more than one place, please combine
kauffj (Migrated from github.com) reviewed 2018-09-25 15:46:45 +02:00
kauffj (Migrated from github.com) left a comment

Looks good overall

Looks good overall
@ -14,6 +14,19 @@ export function clearFile () {
};
}
export function setUpdateTrue () {
kauffj (Migrated from github.com) commented 2018-09-25 15:25:52 +02:00

Is this necessary? My inclination is that there must be another state value corresponding to what is being edited (or even however you ended up on the edit page) that should allow you to know this without an additional explicit value.

Is this necessary? My inclination is that there must be another state value corresponding to what is being edited (or even however you ended up on the edit page) that should allow you to know this without an additional explicit value.
@ -42,3 +42,15 @@ export function getClaimViews (claimId) {
const url = `/api/claim/views/${claimId}`;
return Request(url);
}
kauffj (Migrated from github.com) commented 2018-09-25 15:27:36 +02:00

DRY

DRY
@ -6,3 +5,4 @@
const uri = `/api/claim/${isUpdate ? 'update' : 'publish'}`;
const xhr = new XMLHttpRequest();
// add event listeners
const onLoadStart = () => {
kauffj (Migrated from github.com) commented 2018-09-25 15:29:20 +02:00

I know you didn't add this, but you should know we can just use the Fetch API.

I know you didn't add this, but you should know we can just use the Fetch API.
@ -1,5 +1,6 @@
export const LOAD_START = 'LOAD_START';
export const LOADING = 'LOADING';
kauffj (Migrated from github.com) commented 2018-09-25 15:29:53 +02:00

should be SUCCEEDED fwiw

should be `SUCCEEDED` fwiw
kauffj (Migrated from github.com) commented 2018-09-25 15:31:52 +02:00

if this isn't being fixed before shipping, it needs to be filed, and it's a good practice to link the issue as an inline comment

if this isn't being fixed before shipping, it needs to be filed, and it's a good practice to link the issue as an inline comment
@ -4,1 +4,4 @@
import { LOCAL_CHECK, UNAVAILABLE, ERROR, AVAILABLE } from '../../constants/asset_display_states';
import createCanonicalLink from '../../../../utils/createCanonicalLink';
class AvailableContent extends React.Component {
kauffj (Migrated from github.com) commented 2018-09-25 15:30:44 +02:00

good refactor!

good refactor!
kauffj (Migrated from github.com) commented 2018-09-25 15:32:51 +02:00

better to have this out of the h3 ("edit" isn't part of the title for SEO / accessibility purposes, etc.)

better to have this out of the h3 ("edit" isn't part of the title for SEO / accessibility purposes, etc.)
@ -0,0 +27,4 @@
asset.claimsData.channelName !== myChannel
)
) {
return (<Redirect to={'/'} />);
kauffj (Migrated from github.com) commented 2018-09-25 15:36:18 +02:00

Do we need to redirect to login? Show an error? How would this happen to a user genuinely?

(one guess: sign in in one tab, then sign in a second tab, and click edit from the first tab)

Do we need to redirect to login? Show an error? How would this happen to a user genuinely? (one guess: sign in in one tab, then sign in a second tab, and click edit from the first tab)
@ -14,4 +10,1 @@
}
}
render () {
kauffj (Migrated from github.com) commented 2018-09-25 15:37:51 +02:00

Why does this have to happen here? Does this have to happen for any component that includes <PublishTool />? If so, this should be avoided.

Why does this have to happen here? Does this have to happen for any component that includes `<PublishTool />`? If so, this should be avoided.
@ -0,0 +8,4 @@
route to abandon a claim through the daemon
*/
const claimAbandon = async (req, res) => {
kauffj (Migrated from github.com) commented 2018-09-25 15:42:51 +02:00

This function looks great! Looking forward to more like this

This function looks great! Looking forward to more like this
kauffj (Migrated from github.com) commented 2018-09-25 15:44:16 +02:00

Do these need to be in a transaction if they need to both execute atomically?

Do these need to be in a transaction if they need to both execute atomically?
kauffj (Migrated from github.com) commented 2018-09-25 15:45:39 +02:00

Can be filed, but this is a rather important value that ought to be hoisted all the way to a site-specific config

Can be filed, but this is a rather important value that ought to be hoisted all the way to a site-specific config
daovist (Migrated from github.com) reviewed 2018-09-25 19:44:01 +02:00
@ -14,6 +14,19 @@ export function clearFile () {
};
}
export function setUpdateTrue () {
daovist (Migrated from github.com) commented 2018-09-25 19:44:01 +02:00

I think it would be more complex to do this another way e.g. looking at the router path

I think it would be more complex to do this another way e.g. looking at the router path
daovist (Migrated from github.com) reviewed 2018-09-25 19:44:15 +02:00
@ -0,0 +27,4 @@
asset.claimsData.channelName !== myChannel
)
) {
return (<Redirect to={'/'} />);
daovist (Migrated from github.com) commented 2018-09-25 19:44:15 +02:00

I was only considering a nefarious user. I don't think this matters much; just needs to not render the edit page.

I was only considering a nefarious user. I don't think this matters much; just needs to not render the edit page.
daovist (Migrated from github.com) reviewed 2018-09-26 18:08:01 +02:00
@ -14,4 +10,1 @@
}
}
render () {
daovist (Migrated from github.com) commented 2018-09-26 18:08:00 +02:00

Nice catch/good point! Current speech only clears the file for file errors, reset, publish success, and cancel publish, so two features using the same state.publish were stepping on each others toes

My new approach uses isUpdate

When the publish page mounts: if isUpdate then clearFile

When edit page mounts: if !isUpdate then clearFile, setUpdateTrue, setMetadata

This way a user can start a publish or update, leave the page, and come back to where they were, like current speech, unless they go to the other (Edit/Publish) page, in which case it starts fresh with publish or update

code

Nice catch/good point! Current speech only clears the file for file errors, reset, publish success, and cancel publish, so two features using the same `state.publish` were stepping on each others toes My new approach uses `isUpdate` When the publish page mounts: if `isUpdate` then `clearFile` When edit page mounts: if `!isUpdate` then `clearFile, setUpdateTrue, setMetadata` This way a user can start a publish or update, leave the page, and come back to where they were, like current speech, unless they go to the other (Edit/Publish) page, in which case it starts fresh with publish or update [code](https://github.com/lbryio/spee.ch/pull/595/commits/7c4323ba648fea1e8e2b361a17654b10ae66ff93)
kauffj (Migrated from github.com) reviewed 2018-09-26 20:19:01 +02:00
@ -14,4 +10,1 @@
}
}
render () {
kauffj (Migrated from github.com) commented 2018-09-26 20:19:01 +02:00

👍

:+1:
daovist (Migrated from github.com) reviewed 2018-09-26 21:15:40 +02:00
skhameneh commented 2018-10-26 18:53:18 +02:00 (Migrated from github.com)

Is this ready to test or are we waiting on more daemon changes?

Is this ready to test or are we waiting on more daemon changes?
daovist commented 2018-10-26 19:23:38 +02:00 (Migrated from github.com)

the daemon is good now but I still have a few more things to address, I'll let you know

the daemon is good now but I still have a few more things to address, I'll let you know
skhameneh (Migrated from github.com) approved these changes 2018-11-08 22:56:06 +01:00
skhameneh (Migrated from github.com) commented 2018-11-08 22:46:52 +01:00

store asset.claimData in a local var since it's use many times

store `asset.claimData` in a local var since it's use many times
@ -129,2 +146,2 @@
)}
</div>
</div>
)}
skhameneh (Migrated from github.com) commented 2018-11-08 22:49:27 +01:00

Can use spread operator for switching props, e.g.:

<Elem ...(showSmall ? { small: true } : { small: false }) />
Can use spread operator for switching props, e.g.: ``` <Elem ...(showSmall ? { small: true } : { small: false }) /> ```
skhameneh (Migrated from github.com) commented 2018-11-08 22:52:38 +01:00

Should we order these?

Should we order these?
skhameneh (Migrated from github.com) commented 2018-11-08 22:53:32 +01:00

use the aliases

use the aliases
skhameneh (Migrated from github.com) commented 2018-11-08 22:53:41 +01:00

use aliases

use aliases
@ -18,2 +18,4 @@
const authenticateUser = require('./authentication.js');
const chainquery = require('chainquery');
const createCanonicalLink = require('../../../../../utils/createCanonicalLink');
skhameneh (Migrated from github.com) commented 2018-11-08 22:53:56 +01:00

Use aliases

Use aliases
skhameneh (Migrated from github.com) commented 2018-11-08 22:55:00 +01:00

Use aliases

Use aliases
skhameneh (Migrated from github.com) commented 2018-11-08 22:55:56 +01:00

I'd much prefer to avoid single line if logic, I find it reduced legibility.

I'd much prefer to avoid single line `if` logic, I find it reduced legibility.
daovist (Migrated from github.com) reviewed 2018-11-09 15:52:02 +01:00
daovist (Migrated from github.com) commented 2018-11-09 15:52:02 +01:00

This is for a single claim. I need to do a lookup by channel_id. This can be more generalized in the near future.

This is for a single claim. I need to do a lookup by channel_id. This can be more generalized in the near future.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/spee.ch#595
No description provided.