diff --git a/src/components/UploadModal/index.js b/src/components/UploadModal/index.js index e5085220..4e0c2034 100644 --- a/src/components/UploadModal/index.js +++ b/src/components/UploadModal/index.js @@ -66,7 +66,7 @@ const Upload = props => { {getTranslation("Uploaded at")} {": "} { uploaded_at - ? new Date(uploaded_at).toLocaleString() + ? new Date(uploaded_at * 1000).toLocaleString() : "" } { user.id == 1 && ( diff --git a/src/pages/Perspective/PerspectivePath.js b/src/pages/Perspective/PerspectivePath.js index c022b371..e6676a16 100644 --- a/src/pages/Perspective/PerspectivePath.js +++ b/src/pages/Perspective/PerspectivePath.js @@ -50,7 +50,7 @@ export const queryAvailablePerspectives = gql` const uploadPerspective = gql` mutation uploadPerspective($id: LingvodocID!, $debugFlag: Boolean) { - tsakorpus(perspective_id: $id, debug_flag: $debugFlag) { + tsakorpus(perspective_id: $id, force: true, debug_flag: $debugFlag) { triumph } } diff --git a/src/pages/Perspective/component.js b/src/pages/Perspective/component.js index d9432615..9766dc2d 100644 --- a/src/pages/Perspective/component.js +++ b/src/pages/Perspective/component.js @@ -1113,17 +1113,6 @@ const Filter = handlers(({ value, onChange, onSubmit, isCaseSens, onToggleCaseSe ); }); -const getUploadDate = gql` - query getUploadDate($id: LingvodocID!) { - perspective(id: $id) { - id - additional_metadata { - uploaded_at - } - } - } -`; - const uploadPerspective = gql` mutation uploadPerspective($id: LingvodocID!, $debugFlag: Boolean) { tsakorpus(perspective_id: $id, debug_flag: $debugFlag) { @@ -1151,23 +1140,10 @@ const ModeSelector = compose( }) => { const getTranslation = useContext(TranslationContext); - const {data: dateData, error: dateError, loading: dateLoading, refetch} = ( - useQuery(getUploadDate, { variables: { id }, fetchPolicy: "network-only" })); - const [runUploadPerspective, {data, error, loading}] = ( - useMutation(uploadPerspective, { variables: { id }, onCompleted: refetch })); - - if (dateLoading || dateError) { - return null; - } - - const { - perspective: { additional_metadata: { uploaded_at }} - } = dateData; + useMutation(uploadPerspective, { variables: { id } })); - if (!uploaded_at && !loading && !error && !data) { - runUploadPerspective(); - } + useEffect(() => { runUploadPerspective(); }, []); const modes = {}; if (user.id !== undefined) { @@ -1210,10 +1186,10 @@ const ModeSelector = compose( {info.component === PerspectiveView ? : null} ))} - { (uploaded_at || loading) && ( + { (loading || (!error && data && data.tsakorpus.triumph)) && ( uploaded_at && window.open(`http://83.149.198.78/${id[0]}_${id[1]}/search`, "_blank")} + onClick={() => !loading && window.open(`http://83.149.198.78/${id[0]}_${id[1]}/search`, "_blank")} content={ loading ? (