1
0

store.js 834 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { defineStore } from "pinia";
  2. export const useRadioStore = defineStore("radio", {
  3. state: () => {
  4. return {
  5. radios: {
  6. "https://www.ondarossa.info": {
  7. name: "ROR",
  8. },
  9. "https://radiospore.oziosi.org": {
  10. name: "Spore",
  11. },
  12. },
  13. };
  14. },
  15. getters: {
  16. isRadioReady: (state) => {
  17. return (url) => {
  18. if (state.radios[url] === undefined) {
  19. return false;
  20. }
  21. if (state.radios[url].lastFetch === undefined) {
  22. return false;
  23. }
  24. // XXX: if lastFetch is very old, return false
  25. return true;
  26. };
  27. },
  28. },
  29. actions: {
  30. startFetchingRadio(url) {
  31. return;
  32. },
  33. updateRadio(url, data) {
  34. this.radios[url] = data;
  35. this.radios[url].lastFetch = Date.now();
  36. },
  37. },
  38. });