Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after uploading a torrent. Redirection to all URL with torrent id #97

Closed
josecelano opened this issue Jun 21, 2023 · 1 comment · Fixed by #111
Closed

Error after uploading a torrent. Redirection to all URL with torrent id #97

josecelano opened this issue Jun 21, 2023 · 1 comment · Fixed by #111

Comments

@josecelano
Copy link
Member

josecelano commented Jun 21, 2023

After uploading a torrent, you get this error:

[Vue warn]: Invalid prop: type check failed for prop "torrent". Expected Object, got Null  
  at <TorrentActionCard class="top-8 md:sticky max-w-md" torrent=null onUpdated=fn<reloadTorrent> > 
  at <[infoHash] onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy(Object) {__v_skip: true} > > 
  at <Anonymous key="/torrent/1" routeProps= {Component: {…}, route: {…}} pageKey="/torrent/1"  ... > 
  at <Anonymous > 
  at <RouterView name=undefined route=undefined > 
  at <NuxtPage> 
  at <App key=1 > 
  at <NuxtRoot>

The application tries to navigate to the details URL using the torrent id http://localhost:3000/v1/torrent/1 instead of the info-hash. There is a "TODO":

// TODO: replace torrent_id with info_hash.
function submitForm () {
  uploading.value = true;

  rest.value.torrent.uploadTorrent(
    {
      title: form.value.title,
      category: form.value.category,
      description: form.value.description,
      tags: form.value.tags,
      file: form.value.torrentFile
    }
  )
    .then((torrent_id) => {
      uploading.value = false;

      notify({
        group: "success",
        title: "Success",
        text: "Torrent uploaded!"
      }, 4000);

      navigateTo(`/torrent/${torrent_id}`, { replace: true });
    })
    .catch((err) => {
      uploading.value = false;

      notify({
        group: "error",
        title: "Error",
        text: err
      }, 4000);
    });
}

We have to change the TypeScript wrapper for the backend API:

https://github.com/torrust/torrust-index-api-lib/blob/master/src/modes/rest/resources/torrent.ts#L56-L58

The backend is already returning the info-hash:

https://github.com/torrust/torrust-index-backend/blob/develop/src/web/api/v1/contexts/torrent/responses.rs#L11-L14

@josecelano josecelano added the bug label Jun 21, 2023
@josecelano
Copy link
Member Author

We have to change the API NPM package https://github.com/josecelano/torrust-index-api-lib/issues/1 first.

@josecelano josecelano linked a pull request Jun 23, 2023 that will close this issue
josecelano added a commit that referenced this issue Jun 23, 2023
0f66834 fix: [#97] redirect to torrent details after upload (Jose Celano)

Pull request description:

  The behavior was broken because the navigation (frontend router) used the torrent ID instead of the info-hash. But the API was not returning the info-hash after uploading a new torrent file.

  The API was changed to return the info-hash too. And the API dependency was updated.

Top commit has no ACKs.

Tree-SHA512: c3c8c17fd8cbfc48ff37bc2566e1fb89db660b578d653fc4a35ece722f2b866ea28c7cf6f8fd6636c87de9a28463789cb0e8b4cfd2864d8134fc9d19e79f8019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant