Skip to content

Commit

Permalink
Publish: attempt to handle replay name-clash failures (#2932)
Browse files Browse the repository at this point in the history
## Issue
> Did get a complaint from a user who was unable to edit his livestream placeholder to a replay. It would tell him he has a duplicate claim, so it was sending a stream create vs an edit. Trying to repro how they are getting into that scenario, works normally for us otherwise.

## Possible Root
Wasn't able to replicate, but if the issue is about `stream_create` vs. `stream_update`, then that narrows it down to a missing `claim_id` when creating the payload.

The use of `selectMyClaimForUri` to get the claim-being-edited has always been sketchy, since that depends network fetches and a ton of logic. Most likely it returned undefined here.

## Change
With recent changes, we are now storing `claimToEdit` in Redux and persisting it over F5. That object is guaranteed to be populated first before entering Edit stage, so derivation isn't necessary anymore.
  • Loading branch information
infinite-persistence authored Aug 22, 2023
1 parent aa05c23 commit bd92ac6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions ui/redux/actions/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
import {
selectPublishFormValue,
selectPublishFormValues,
selectMyClaimForUri,
selectIsStillEditing,
selectMemberRestrictionStatus,
} from 'redux/selectors/publish';
Expand Down Expand Up @@ -594,9 +593,6 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string, claimType: string
} = value;

let state = getState();
const myClaimForUri = selectMyClaimForUri(state);
const { claim_id } = myClaimForUri || {};
// ^--- can we just use 'claim.claim_id'?

const isPostClaim = makeSelectFileRenderModeForUri(claim?.permanent_url)(state) === RENDER_MODES.MARKDOWN;
const isLivestreamClaim = isStreamPlaceholderClaim(claim);
Expand All @@ -614,7 +610,7 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string, claimType: string
type,
...(liveCreateType ? { liveCreateType } : {}),
...(liveEditType ? { liveEditType } : {}),
claim_id: claim_id,
claim_id: claim.claim_id,
name,
bid: Number(amount),
author,
Expand Down Expand Up @@ -760,13 +756,13 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string, claimType: string

export const doPublish =
(success: Function, fail: Function, previewFn?: Function, payload?: FileUploadSdkParams) =>
(dispatch: Dispatch, getState: () => {}) => {
(dispatch: Dispatch, getState: GetState) => {
if (!previewFn) {
dispatch({ type: ACTIONS.PUBLISH_START });
}

const state = getState();
const myClaimForUri = selectMyClaimForUri(state);
const myClaimForUri = state.publish.claimToEdit;
const myChannels = selectMyChannelClaims(state);
// const myClaims = selectMyClaimsWithoutChannels(state);
// get redux publish form
Expand All @@ -780,7 +776,7 @@ export const doPublish =

const { channel_id: channelClaimId } = publishPayload;

const existingClaimId = myClaimForUri?.claim_id;
const existingClaimId = myClaimForUri?.claim_id || '';

// hit backend to save restricted memberships
// hit the backend immediately to save the data, we will overwrite it if publish succeeds
Expand Down

0 comments on commit bd92ac6

Please sign in to comment.