From e6e4b5784d83d78b38c3e032a7e8fc214560aeec Mon Sep 17 00:00:00 2001 From: pichalite Date: Tue, 2 Feb 2016 15:43:21 -0800 Subject: [PATCH 1/2] remove unused code --- public/src/client/account/profile.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js index 01d5475c22..0d59a96df1 100644 --- a/public/src/client/account/profile.js +++ b/public/src/client/account/profile.js @@ -9,21 +9,16 @@ define('forum/account/profile', [ 'components' ], function(header, infinitescroll, translator) { var Account = {}, - yourid, - theirid, - isFollowing; + theirid; Account.init = function() { header.init(); - yourid = ajaxify.data.yourid; theirid = ajaxify.data.theirid; - isFollowing = ajaxify.data.isFollowing; app.enterRoom('user/' + theirid); processPage(); - updateButtons(); socket.removeListener('event:user_status_change', onUserStatusChange); socket.on('event:user_status_change', onUserStatusChange); @@ -35,13 +30,6 @@ define('forum/account/profile', [ $('[component="posts"] img:not(.not-responsive), [component="aboutme"] img:not(.not-responsive)').addClass('img-responsive'); } - function updateButtons() { - var isSelfOrNotLoggedIn = yourid === theirid || parseInt(yourid, 10) === 0; - $('#follow-btn').toggleClass('hide', isFollowing || isSelfOrNotLoggedIn); - $('#unfollow-btn').toggleClass('hide', !isFollowing || isSelfOrNotLoggedIn); - $('#chat-btn').toggleClass('hide', isSelfOrNotLoggedIn); - } - function onUserStatusChange(data) { if (parseInt(ajaxify.data.theirid, 10) !== parseInt(data.uid, 10)) { return; From ee47a135569dcfa274cab30e21a0e9efd6cd57c2 Mon Sep 17 00:00:00 2001 From: pichalite Date: Tue, 2 Feb 2016 15:44:49 -0800 Subject: [PATCH 2/2] use components --- public/src/client/account/header.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/src/client/account/header.js b/public/src/client/account/header.js index 2447920d04..6449ac839f 100644 --- a/public/src/client/account/header.js +++ b/public/src/client/account/header.js @@ -90,8 +90,8 @@ define('forum/account/header', [ return app.alertError(err.message); } - $('#follow-btn').toggleClass('hide', type === 'follow'); - $('#unfollow-btn').toggleClass('hide', type === 'unfollow'); + components.get('account/follow').toggleClass('hide', type === 'follow'); + components.get('account/unfollow').toggleClass('hide', type === 'unfollow'); app.alertSuccess('[[global:alert.' + type + ', ' + ajaxify.data.username + ']]'); }); return false;