Publish: handle failed 'notify' at the server

Ticket: 1256

For `notify`, "file is currently locked" and "no such file or directory" is indication that the previous "failed" SDK call actually worked. Tell the user to check the transactions.

This is the band aid until odysee-api/401 is addressed.
This commit is contained in:
infinite-persistence 2022-04-04 13:51:45 +08:00 committed by Thomas Zarebczan
parent 234bd2526a
commit 89feddee0d
5 changed files with 20 additions and 2 deletions

View file

@ -1 +1,2 @@
**/plugins/inline-attachment/**
**/ui/constants/errors.js

View file

@ -2230,5 +2230,6 @@
"Active channel": "Active channel",
"This account has livestreaming disabled, please reach out to hello@odysee.com for assistance.": "This account has livestreaming disabled, please reach out to hello@odysee.com for assistance.",
"Attach images by pasting or drag-and-drop.": "Attach images by pasting or drag-and-drop.",
"There was a network error, but the publish may have been completed. Wait a few minutes, then check your Uploads or Wallet page to confirm.": "There was a network error, but the publish may have been completed. Wait a few minutes, then check your Uploads or Wallet page to confirm.",
"--end--": "--end--"
}

View file

@ -1,2 +1,3 @@
export const ALREADY_CLAIMED = 'once the invite reward has been claimed the referrer cannot be changed';
export const REFERRER_NOT_FOUND = 'A odysee account could not be found for the referrer you provided.';
export const PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL = 'There was a network error, but the publish may have been completed. Wait a few minutes, then check your Uploads or Wallet page to confirm.';

View file

@ -1,4 +1,5 @@
// @flow
import { PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL } from 'constants/errors';
import * as MODALS from 'constants/modal_types';
import * as ACTIONS from 'constants/action_types';
import * as PAGES from 'constants/pages';
@ -14,7 +15,7 @@ import {
selectReflectingById,
} from 'redux/selectors/claims';
import { makeSelectPublishFormValue, selectPublishFormValues, selectMyClaimForUri } from 'redux/selectors/publish';
import { doError } from 'redux/actions/notifications';
import { doError, doToast } from 'redux/actions/notifications';
import { push } from 'connected-react-router';
import analytics from 'analytics';
import { doOpenModal, doSetIncognito, doSetActiveChannel } from 'redux/actions/app';
@ -282,7 +283,13 @@ export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispat
actions.push({
type: ACTIONS.PUBLISH_FAIL,
});
actions.push(doError({ message: error.message, cause: error.cause }));
if (error.message === PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL) {
actions.push(doToast({ message: error.message, duration: 'long' }));
} else {
actions.push(doError({ message: error.message, cause: error.cause }));
}
dispatch(batchActions(...actions));
};

View file

@ -3,6 +3,7 @@ import * as tus from 'tus-js-client';
import { v4 as uuid } from 'uuid';
import { makeUploadRequest } from './publish-v1';
import { makeResumableUploadRequest } from './publish-v2';
import { PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL } from 'constants/errors';
// A modified version of Lbry.apiCall that allows
// to perform calling methods at arbitrary urls
@ -54,6 +55,13 @@ export default function apiPublishCallViaWeb(
if (xhr.status >= 200 && xhr.status < 300 && !xhr.response.error) {
return resolve(xhr.response.result);
} else if (xhr.response.error) {
if (xhr.responseURL.endsWith('/notify')) {
// Temp handling until odysee-api/issues/401 is addressed.
const errMsg = xhr.response.error.message;
if (errMsg === 'file currently locked' || errMsg.endsWith('no such file or directory')) {
return Promise.reject(new Error(PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL));
}
}
error = new Error(xhr.response.error.message);
} else {
error = new Error(__('Upload likely timed out. Try a smaller file while we work on this.'));