add accurate loading states in all views

This commit is contained in:
Tom
2023-05-07 16:50:05 +02:00
parent e11599a452
commit c7b281ff01
6 changed files with 47 additions and 27 deletions
+23 -14
View File
@@ -1,18 +1,27 @@
function formatState(str) {
return (
str
.replace(/-/g, " ")
.split(" ")
.map((word) => {
word = word.toLowerCase();
if (word === "ipfs" || word === "ipns") {
return word.toUpperCase();
} else {
return word.charAt(0).toUpperCase() + word.slice(1);
}
})
.join(" ") + "..."
);
if (!str) {
return null;
}
const formattedWords = str
.replace(/-/g, " ")
.split(" ")
.map((word, index) => {
word = word.toLowerCase();
if (word === "ipfs" || word === "ipns") {
return word.toUpperCase();
} else if (index === 0) {
return word.charAt(0).toUpperCase() + word.slice(1);
} else {
return word;
}
});
if (formattedWords.includes("Failed")) {
return formattedWords.join(" ") + ".";
}
return formattedWords.join(" ") + "...";
}
export default formatState;
+10
View File
@@ -0,0 +1,10 @@
const isValidUrl = (url) => {
try {
new URL(url);
return true;
} catch (e) {
return false;
}
};
export default isValidUrl;