Skip to content

Commit

Permalink
Merge pull request #63 from ahmadfh/master
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
DanielHindi authored Mar 11, 2017
2 parents 6c2c994 + f94528c commit 08c2a19
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 10 deletions.
2 changes: 1 addition & 1 deletion widget/app.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
if(obj.url && obj.url.indexOf('http') !== 0 && obj.url.indexOf('https') !== 0){
obj.url = 'http://' + obj.url;
}
lookup.push("<a href='" + obj.url + "' target='" + obj.target + "' inappbrowser='true'>" + url + "</a>");
lookup.push("<a href='" + obj.url + "' target='" + obj.target + "' >" + url + "</a>");
return "_RF" + (lookup.length -1) + "_";
});
if(!options.emailAnchorGen)
Expand Down
26 changes: 25 additions & 1 deletion widget/controllers/widget.thread.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
31 changes: 28 additions & 3 deletions widget/controllers/widget.wall.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions widget/templates/thread.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@
</div>
<div class="user-info">
<div class="media-holder ng-cloak"
ng-click="Thread.buildfire.auth.openProfile(Thread.SocialItems.userDetails.userId)">
<img ng-if="Thread.getUserImage(Thread.SocialItems.userDetails.userId)" load-image="1x1"
data-final-src="{{Thread.usersData | getUserImage: Thread.SocialItems.userDetails.userId}}"
ng-click="Thread.buildfire.auth.openProfile(Thread.userDetails.userId)">
<img ng-if="Thread.getUserImage(Thread.userDetails.userId)" load-image="1x1"
data-final-src="{{Thread.usersData | getUserImage: Thread.userDetails.userId}}"
crop-width="50" crop-height="50" crop-type="crop">
<img ng-if="!Thread.getUserImage(Thread.SocialItems.userDetails.userId)" load-image="1x1"
<img ng-if="!Thread.getUserImage(Thread.userDetails.userId)" load-image="1x1"
data-final-src="../../../styles/media/avatar-placeholder.png"
crop-width="50" crop-height="50" crop-type="default">
<a class="user-name text-primary ng-cloak"
ng-click="Thread.buildfire.auth.openProfile(Thread.SocialItems.userDetails.userId)">{{Thread.getUserName(Thread.SocialItems.userDetails.userId)}}</a>
ng-click="Thread.buildfire.auth.openProfile(Thread.userDetails.userId)">{{Thread.getUserName(Thread.userDetails.userId)}}</a>
</div>
</div>
<div class="add-message">
Expand Down

0 comments on commit 08c2a19

Please sign in to comment.