Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 23, 2024
2 parents fb1dc43 + 9d833f5 commit 0068a3d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
42 changes: 42 additions & 0 deletions client-next/public/js/particles-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
particlesJS('background', {
particles: {
number: { value: 80, density: { enable: true, value_area: 800 } },
color: { value: '#ffffff' },
shape: { type: 'circle' },
opacity: {
value: 0.5,
random: false,
anim: { enable: false }
},
size: {
value: 3,
random: true,
anim: { enable: false }
},
line_linked: {
enable: true,
distance: 150,
color: '#ffffff',
opacity: 0.4,
width: 1
},
move: {
enable: true,
speed: 6,
direction: 'none',
random: false,
straight: false,
out_mode: 'out',
bounce: false
}
},
interactivity: {
detect_on: 'canvas',
events: {
onhover: { enable: true, mode: 'repulse' },
onclick: { enable: true, mode: 'push' },
resize: true
}
},
retina_detect: true
});
7 changes: 3 additions & 4 deletions client/js/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function updateWearButton(type, itemId, isWearing) {

function loadUserAvatar() {
const token = localStorage.getItem('token');
console.log("hahaahsha");
$.ajax({
url: '/api/avatar',
method: 'GET',
Expand All @@ -318,10 +319,8 @@ function loadUserAvatar() {
},
success: function (avatar) {
if (avatar.shirt && avatar.shirt._id) {
updateAvatarDisplay('shirt', avatar.shirt);
updateCurrentlyWearing('shirt', avatar.shirt);
updateWearButton('shirt', avatar.shirt._id, true);
}
wearItem('shirt', avatar.shirtId);
}
},
error: function (xhr, status, error) {
console.error('Error loading avatar:', error);
Expand Down
9 changes: 9 additions & 0 deletions server/functions/api/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ const userSchema = new mongoose.Schema({
verificationToken: {
type: String,
},
avatar: {
shirt: { type: mongoose.Schema.Types.ObjectId, ref: 'Asset', default: null },
pants: { type: mongoose.Schema.Types.ObjectId, ref: 'Asset', default: null },
hat: { type: mongoose.Schema.Types.ObjectId, ref: 'Asset', default: null },
gear: { type: mongoose.Schema.Types.ObjectId, ref: 'Asset', default: null },
heads: { type: mongoose.Schema.Types.ObjectId, ref: 'Asset', default: null },
face: { type: mongoose.Schema.Types.ObjectId, ref: 'Asset', default: null },
tshirts: { type: mongoose.Schema.Types.ObjectId, ref: 'Asset', default: null }
},
signupDate: {
type: Date,
default: () => moment().tz('America/New_York').toDate(),
Expand Down
5 changes: 4 additions & 1 deletion server/functions/api/routes/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const Asset = require('../models/Asset');

// Get current avatar
router.get('/', authenticateToken, async (req, res) => {
res.set('Cache-Control', 'no-cache');
res.set('Pragma', 'no-cache');
res.set('Expires', '0');
try {
console.log('Fetching avatar for userId:', req.user.userId);
const user = await User.findOne({ userId: req.user.userId }).select('avatar');
Expand Down Expand Up @@ -96,4 +99,4 @@ router.put('/', authenticateToken, async (req, res) => {
}
});

module.exports = router;
module.exports = router;

0 comments on commit 0068a3d

Please sign in to comment.