Added tokelist to user profile.

This commit is contained in:
rainbow napkin 2024-12-14 07:03:25 -05:00
parent 0b84c51cbf
commit 80f0c5435f
6 changed files with 79 additions and 7 deletions

View file

@ -37,6 +37,7 @@ module.exports.get = async function(req, res){
user: userDB.user,
date: userDB.date,
tokes: userDB.tokes,
tokeCount: userDB.getTokeCount(),
img: userDB.img,
signature: userDB.signature,
bio: userDB.bio

View file

@ -283,6 +283,20 @@ userSchema.methods.setFlair = async function(flair){
return flairDB;
}
userSchema.methods.getTokeCount = function(){
//Set tokeCount to 0
var tokeCount = 0;
//For each toke command the user has used
this.tokes.forEach((commandCount) => {
//Add the count for that specific command to the total
tokeCount += commandCount;
});
//Return the amount of tokes recorded
return tokeCount;
}
//note: if you gotta call this from a request authenticated by it's user, make sure to kill that session first!
userSchema.methods.killAllSessions = async function(reason = "A full log-out from all devices was requested for your account."){
//get authenticated sessions

View file

@ -34,8 +34,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
<% if(selfProfile){ %>
<p class="profile-item-edit">(<a class="profile-item-edit" id="profile-img-edit" href="javascript:">edit</a>)</p>
<% } %>
<p class="profile-item" id="profile-tokes">tokes: <%- profile.tokes %> (Not yet implemented)</p>
<span class="profile-item profile-toke-count">
<p class="profile-item profile-toke-count">tokes: <%- profile.tokeCount %> </p>
<i class="profile-item bi-caret-left-fill profile-toke-count" id="toggle-toke-list"></i>
</span>
<div class="profile-item dynamic-container" id="profile-tokes">
<% profile.tokes.forEach((count, toke) => { %>
<p class="profile-item profile-toke" id='profile-tokes<%-toke%>'>!<%- toke %>: <%- count %></p>
<% }); %>
</div>
<span class="profile-item" id="profile-signature">
<p class="profile-item profile-item-label" id="profile-signature-label">Signature: <span class="profile-content" id="profile-signature-content"><%- profile.signature %></span></p>
<% if(selfProfile){ %>