Fix preview delay on Web by sending a dummy file.

This commit is contained in:
infiinte-persistence 2020-10-01 14:24:52 +08:00 committed by Sean Yesmunt
parent 92b211dd94
commit 985aada5e4

View file

@ -16,18 +16,24 @@ export default function apiPublishCallViaWeb(
connectionString: string, connectionString: string,
token: string, token: string,
method: string, method: string,
params: { file_path: string }, params: { file_path: string, preview: boolean },
resolve: Function, resolve: Function,
reject: Function reject: Function
) { ) {
const { file_path: filePath } = params; const { file_path: filePath, preview } = params;
if (!filePath) { if (!filePath) {
return apiCall(method, params, resolve, reject); return apiCall(method, params, resolve, reject);
} }
const counter = new Date().getTime(); const counter = new Date().getTime();
const fileField = filePath; let fileField = filePath;
if (preview) {
// Send dummy file for the preview. The tx-fee calculation does not depend on it.
const dummyContent = 'x';
fileField = new File([dummyContent], 'dummy.md', { type: 'text/markdown' });
}
// Putting a dummy value here, the server is going to process the POSTed file // Putting a dummy value here, the server is going to process the POSTed file
// and set the file_path itself // and set the file_path itself