Simplify Current JS implementation

This commit is contained in:
Jose Farias
2024-10-12 23:06:34 -06:00
parent 2c6c821e20
commit bb5b0701ed
5 changed files with 17 additions and 28 deletions
+15
View File
@@ -0,0 +1,15 @@
class Current {
get user() {
const currentUserId = this.#extractContentFromMetaTag("current-user-id")
if (currentUserId) {
return { id: parseInt(currentUserId) }
}
}
#extractContentFromMetaTag(name) {
return document.head.querySelector(`meta[name="${name}"]`)?.getAttribute("content")
}
}
window.Current = new Current()