useSearchSoundcloud.ts 723 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { ref } from "vue";
  2. import Toast from "toasters";
  3. import { useWebsocketsStore } from "@/stores/websockets";
  4. export const useSearchSoundcloud = () => {
  5. const soundcloudSearch = ref({
  6. songs: {
  7. results: [],
  8. query: "",
  9. nextPageToken: ""
  10. },
  11. playlist: {
  12. query: ""
  13. }
  14. });
  15. const { socket } = useWebsocketsStore();
  16. const addSoundcloudSongToPlaylist = (playlistId, id, index) => {
  17. socket.dispatch(
  18. "playlists.addSongToPlaylist",
  19. false,
  20. id,
  21. playlistId,
  22. res => {
  23. new Toast(res.message);
  24. if (res.status === "success")
  25. soundcloudSearch.value.songs.results[index].isAddedToQueue =
  26. true;
  27. }
  28. );
  29. };
  30. return {
  31. soundcloudSearch,
  32. addSoundcloudSongToPlaylist
  33. };
  34. };