mirror of
https://github.com/arnaucube/openEventsPlatformApp.git
synced 2026-02-07 11:46:39 +01:00
users following system implemented
This commit is contained in:
@@ -24,4 +24,32 @@ angular.module('app.users', ['pascalprecht.translate'])
|
||||
};
|
||||
$scope.doRefresh();
|
||||
|
||||
$scope.followingUsers=[];
|
||||
$scope.$on('$ionicView.enter', function(){//per executar-ho cada cop que es carrega el view
|
||||
if (localStorage.getItem("events_app_followingUsers")) {
|
||||
$scope.followingUsers = JSON.parse(localStorage.getItem("events_app_followingUsers"));
|
||||
console.log("followingUsers");
|
||||
console.log($scope.followingUsers);
|
||||
}
|
||||
});
|
||||
$scope.followUser = function(user){
|
||||
$scope.followingUsers.push(user);
|
||||
localStorage.setItem("events_app_followingUsers", JSON.stringify($scope.followingUsers));
|
||||
};
|
||||
$scope.unfollowUser = function(user){
|
||||
for(var i=0; i<$scope.followingUsers.length; i++) {
|
||||
if ($scope.followingUsers[i]._id === user._id){
|
||||
$scope.followingUsers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
localStorage.setItem("events_app_followingUsers", JSON.stringify($scope.followingUsers));
|
||||
};
|
||||
$scope.isUserFollowed = function(user) {
|
||||
for(var i=0; i<$scope.followingUsers.length; i++) {
|
||||
if ($scope.followingUsers[i]._id === user._id){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
});
|
||||
|
||||
@@ -5,14 +5,27 @@
|
||||
on-refresh="doRefresh()">
|
||||
</ion-refresher>
|
||||
<ion-list><!-- item-remove-animate -->
|
||||
<ion-item class="item-avatar item-icon-right"
|
||||
ng-repeat="user in users" type="item-text-wrap" href="#/app/users/{{user._id}}">
|
||||
<div ng-repeat="user in users">
|
||||
<div class="item-note">
|
||||
<div class="button button-small button-assertive"
|
||||
ng-show="isUserFollowed(user)"
|
||||
ng-click="unfollowUser(user)">
|
||||
Unfollow
|
||||
</div>
|
||||
<div class="button button-small button-balanced"
|
||||
ng-hide="isUserFollowed(user)"
|
||||
ng-click="followUser(user)">
|
||||
Follow
|
||||
</div>
|
||||
</div>
|
||||
<ion-item class="item-avatar"
|
||||
type="item-text-wrap" href="#/app/users/{{user._id}}">
|
||||
<img ng-src="{{user.img}}">
|
||||
|
||||
<h2>{{user.username}}</h2>
|
||||
<p>{{user.shortDescription}}</p>
|
||||
|
||||
<span class="badge badge-balanced">Following</span>
|
||||
</ion-item>
|
||||
</div>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
||||
Reference in New Issue
Block a user