From f94528cdf0799b9eb3f1995fc265ba92e46a076f Mon Sep 17 00:00:00 2001 From: Ahmad Farouq Hamed Date: Sat, 11 Mar 2017 16:40:04 +0200 Subject: [PATCH] fix url blank page in comments & post fix user image & name in comment box --- widget/app.service.js | 2 +- .../controllers/widget.thread.controller.js | 26 +++++++++++++++- widget/controllers/widget.wall.controller.js | 31 +++++++++++++++++-- widget/templates/thread.html | 10 +++--- 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/widget/app.service.js b/widget/app.service.js index 5f46265..0585882 100644 --- a/widget/app.service.js +++ b/widget/app.service.js @@ -66,7 +66,7 @@ if(obj.url && obj.url.indexOf('http') !== 0 && obj.url.indexOf('https') !== 0){ obj.url = 'http://' + obj.url; } - lookup.push("" + url + ""); + lookup.push("" + url + ""); return "_RF" + (lookup.length -1) + "_"; }); if(!options.emailAnchorGen) diff --git a/widget/controllers/widget.thread.controller.js b/widget/controllers/widget.thread.controller.js index cfa23cd..8e92b8a 100644 --- a/widget/controllers/widget.thread.controller.js +++ b/widget/controllers/widget.thread.controller.js @@ -60,6 +60,29 @@ $scope.$digest(); }; + var getUserData = function (userId) { + if(userId){ + if (userIds.indexOf(userId.toString()) == -1) { + userIds.push(userId.toString()); + } + var successCallback = function (response) { + if (response.data.error) { + console.error('Error while fetching users ', response.data.error); + } else if (response.data.result) { + console.info('Users fetched successfully', response.data.result); + Thread.usersData = response.data.result; + if (!$scope.$$phase) $scope.$digest(); + } + }; + var errorCallback = function (err) { + console.log('Error while fetching users details ', err); + + if (!$scope.$$phase) $scope.$digest(); + }; + SocialDataStore.getUsers(userIds, Thread.userDetails.userToken).then(successCallback, errorCallback); + } + }; + Thread.getComments = function (postId, lastCommentId) { SocialDataStore.getCommentsOfAPost({ @@ -144,7 +167,6 @@ Thread.userDetails.userId = userData._id; Thread.userDetails.userToken = userData.userToken; Thread.userDetails.userTags = userData.tags; - Buildfire.datastore.get('Social', function (err, SocialData) { if (err) { console.error('Side Thread Get Social settings', err); @@ -214,6 +236,7 @@ var checkUserPromise = checkAuthenticatedUser(true); checkUserPromise.then(function () { + getUserData(Thread.userDetails.userId); SocialDataStore.getThreadLikes(uniqueIdsArray, Thread.SocialItems.socialAppId, Thread.userDetails.userId).then(function (response) { console.info('get thread likes response is: ', response.data.result); if (response.data.error) { @@ -787,6 +810,7 @@ if (user && user._id) { Thread.userDetails.userToken = user.userToken; Thread.userDetails.userId = user._id; + getUserData(user._id); //check user if has permission to create thread Thread.showHideCommentBox(); $scope.$digest(); diff --git a/widget/controllers/widget.wall.controller.js b/widget/controllers/widget.wall.controller.js index b0f8d60..6d93321 100644 --- a/widget/controllers/widget.wall.controller.js +++ b/widget/controllers/widget.wall.controller.js @@ -61,6 +61,27 @@ } }; + var getUserData = function (userId) { + if (userIds.indexOf(userId.toString()) == -1) { + userIds.push(userId.toString()); + } + var successCallback = function (response) { + + if (response.data.error) { + console.error('Error while fetching users ', response.data.error); + } else if (response.data.result) { + console.info('Users fetched successfully', response.data.result); + WidgetWall.usersData = response.data.result; + } + }; + var errorCallback = function (err) { + console.log('Error while fetching users details ', err); + + if (!$scope.$$phase) $scope.$digest(); + }; + SocialDataStore.getUsers(userIds, WidgetWall.SocialItems.userDetails.userToken).then(successCallback, errorCallback); + } + WidgetWall.init = function () { WidgetWall.SocialItems.init(); WidgetWall.SocialItems.posts(); @@ -70,6 +91,7 @@ } else { //check if user logged in if (WidgetWall.SocialItems.userDetails.userId != null) { + getUserData(WidgetWall.SocialItems.userDetails.userId); //check user if has permission to create thread WidgetWall.showHideCommentBox(); } @@ -609,9 +631,11 @@ userIds.push(postData.userId.toString()); newUserIds.push(postData.userId.toString()); } - if (postsUniqueIds.indexOf(postData.uniqueLink.toString()) == -1) { - postsUniqueIds.push(postData.uniqueLink); - newPostsUniqueIds.push(postData.uniqueLink); + if(postData.uniqueLink){ + if (postsUniqueIds.indexOf(postData.uniqueLink.toString()) == -1) { + postsUniqueIds.push(postData.uniqueLink); + newPostsUniqueIds.push(postData.uniqueLink); + } } }); var successCallback = function (response) { @@ -735,6 +759,7 @@ if (user && user._id) { WidgetWall.SocialItems.userDetails.userToken = user.userToken; WidgetWall.SocialItems.userDetails.userId = user._id; + getUserData(user._id); //check user if has permission to create thread WidgetWall.showHideCommentBox(); $scope.$digest(); diff --git a/widget/templates/thread.html b/widget/templates/thread.html index c140917..150bc7f 100644 --- a/widget/templates/thread.html +++ b/widget/templates/thread.html @@ -161,15 +161,15 @@
- + - {{Thread.getUserName(Thread.SocialItems.userDetails.userId)}} + ng-click="Thread.buildfire.auth.openProfile(Thread.userDetails.userId)">{{Thread.getUserName(Thread.userDetails.userId)}}