Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
follow/unfollow/mute/unmute fixes mentioned in #74 and #61
Browse files Browse the repository at this point in the history
  • Loading branch information
talhasch committed Jun 9, 2018
1 parent d8d711d commit e815047
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
8 changes: 4 additions & 4 deletions app/templates/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<div class="the-author" ng-if="!loadingAuthor" ng-class="{'fetching': loadingAuthor}">
<header class="author-header">
<div class="control-box" ng-class="{'fetching': loadingVisitor}" ng-show="!isMyPage">
<button class="btn btn-default btn-follow" ng-if="visitorData.canFollow" login-required required-keys="'active,owner'" on-login-success="follow()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vFollowing"></i> {{ 'FOLLOW' | translate }}</button>
<button class="btn btn-default btn-unfollow" ng-if="visitorData.canUnfollow" ng-click="unfollow()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnfollowing"></i> {{ 'UNFOLLOW' | translate }}</button>
<button class="btn btn-default btn-mute" ng-if="visitorData.canMute" ng-disabled="loadingVisitor || vBlockControl" ng-click="mute()"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vMuting"></i> {{ 'MUTE' | translate }}</button>
<button class="btn btn-default btn-unmute" ng-if="visitorData.canUnmute" ng-disabled="loadingVisitor || vBlockControl" ng-click="unMute()"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnmuting"></i> {{ 'UNMUTE' | translate }}</button>
<button class="btn btn-default btn-follow" ng-if="visitorData.canFollow" login-required required-keys="'posting'" on-login-success="follow()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vFollowing"></i> {{ 'FOLLOW' | translate }}</button>
<button class="btn btn-default btn-unfollow" ng-if="visitorData.canUnfollow" login-required required-keys="'posting'" on-login-success="unfollow()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnfollowing"></i> {{ 'UNFOLLOW' | translate }}</button>
<button class="btn btn-default btn-mute" ng-if="visitorData.canMute" login-required required-keys="'posting'" on-login-success="mute()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vMuting"></i> {{ 'MUTE' | translate }}</button>
<button class="btn btn-default btn-unmute" ng-if="visitorData.canUnmute" login-required required-keys="'posting'" on-login-success="unMute()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnmuting"></i> {{ 'UNMUTE' | translate }}</button>
</div>
<div class="control-box2" ng-class="{'fetching': loadingVisitor}" ng-show="!isMyPage">
<button class="btn btn-default btn-fav" ng-if="!visitorData.favorited" ng-disabled="loadingVisitor || vFavoriting" login-required on-login-success="fav()" title="{{ 'FAVORITES_ADD' | __ }}"><i class="fa fa-heart-o"></i></button>
Expand Down
10 changes: 5 additions & 5 deletions app/templates/directives/author-name-popover.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<div class="author-name"><a ng-click="goToAuthor()">{{ name }}</a></div>
<div class="author-username"><a ng-click="goToAuthor()">@{{ username }}</a></div>
<div class="author-follow">
<button class="btn btn-primary btn-sm btn-follow" ng-if="!visitorName && visitorData.canFollow" login-required required-keys="'active,owner'" on-login-success="loginSuccess()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"> {{ 'FOLLOW' | translate }}</button>
<button class="btn btn-primary btn-sm btn-follow" ng-if="visitorName && visitorData.canFollow" login-required required-keys="'active,owner'" on-login-success="follow()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vFollowing"></i> {{ 'FOLLOW' | translate }}</button>
<button class="btn btn-primary btn-sm btn-unfollow" ng-if="visitorName && visitorData.canUnfollow" login-required required-keys="'active,owner'" on-login-success="unfollow()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnfollowing"></i> {{ 'UNFOLLOW' | translate }}</button>
<button class="btn btn-primary btn-sm btn-mute" ng-if="visitorName && visitorData.canMute" login-required required-keys="'active,owner'" on-login-success="mute()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vMuting"></i> {{ 'MUTE' | translate }}</button>
<button class="btn btn-primary btn-sm btn-unmute" ng-if="visitorName && visitorData.canUnmute" login-required required-keys="'active,owner'" on-login-success="unMute()" on-login-open="loginDialogOpened()" ng-click="unMute()"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnmuting"></i> {{ 'UNMUTE' | translate }}</button>
<button class="btn btn-primary btn-sm btn-follow" ng-if="!visitorName && visitorData.canFollow" login-required required-keys="'posting'" on-login-success="loginSuccess()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"> {{ 'FOLLOW' | translate }}</button>
<button class="btn btn-primary btn-sm btn-follow" ng-if="visitorName && visitorData.canFollow" login-required required-keys="'posting'" on-login-success="follow()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vFollowing"></i> {{ 'FOLLOW' | translate }}</button>
<button class="btn btn-primary btn-sm btn-unfollow" ng-if="visitorName && visitorData.canUnfollow" login-required required-keys="'posting'" on-login-success="unfollow()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnfollowing"></i> {{ 'UNFOLLOW' | translate }}</button>
<button class="btn btn-primary btn-sm btn-mute" ng-if="visitorName && visitorData.canMute" login-required required-keys="'posting'" on-login-success="mute()" on-login-open="loginDialogOpened()" ng-disabled="loadingVisitor || vBlockControl"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vMuting"></i> {{ 'MUTE' | translate }}</button>
<button class="btn btn-primary btn-sm btn-unmute" ng-if="visitorName && visitorData.canUnmute" login-required required-keys="'posting'" on-login-success="unMute()" on-login-open="loginDialogOpened()" ng-click="unMute()"><i class="fa fa-spin fa-spinner fa-circle-o-notch" ng-if="vUnmuting"></i> {{ 'UNMUTE' | translate }}</button>
</div>
</div>
<br clear="all">
Expand Down
13 changes: 6 additions & 7 deletions src/controllers/author.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,7 @@ export default ($scope, $rootScope, $routeParams, $timeout, $q, $location, $wind
steemAuthenticatedService.follow(username).then((resp) => {
afterFollow();
}).catch((e) => {
// TODO: handle error
console.log(e)
$rootScope.showError(e);
}).then(() => {
$scope.vBlockControl = false;
$scope.vFollowing = false;
Expand All @@ -483,7 +482,7 @@ export default ($scope, $rootScope, $routeParams, $timeout, $q, $location, $wind
steemAuthenticatedService.unfollow(username).then((resp) => {
afterUnfollow();
}).catch((e) => {
// TODO: handle error
$rootScope.showError(e);
}).then(() => {
$scope.vBlockControl = false;
$scope.vUnfollowing = false;
Expand All @@ -505,7 +504,7 @@ export default ($scope, $rootScope, $routeParams, $timeout, $q, $location, $wind
steemAuthenticatedService.mute(username).then((resp) => {
afterMute();
}).catch((e) => {
// TODO: handle error
$rootScope.showError(e);
}).then(() => {
$scope.vBlockControl = false;
$scope.vMuting = false;
Expand All @@ -527,7 +526,7 @@ export default ($scope, $rootScope, $routeParams, $timeout, $q, $location, $wind
steemAuthenticatedService.unfollow(username).then((resp) => {
afterUnmute();
}).catch((e) => {
// TODO: handle error
$rootScope.showError(e);
}).then(() => {
$scope.vBlockControl = false;
$scope.vUnmuting = false;
Expand All @@ -536,7 +535,7 @@ export default ($scope, $rootScope, $routeParams, $timeout, $q, $location, $wind

$scope.fav = () => {
$scope.vFavoriting = true;
eSteemService.addFavorite(activeUsername(), username).then((resp)=>{
eSteemService.addFavorite(activeUsername(), username).then((resp) => {
$scope.visitorData.favorited = true;
$rootScope.$broadcast('favoritesChanged');
}).catch((e) => {
Expand All @@ -548,7 +547,7 @@ export default ($scope, $rootScope, $routeParams, $timeout, $q, $location, $wind

$scope.unFav = () => {
$scope.vFavoriting = true;
eSteemService.removeFavoriteUser(activeUsername(), username).then((resp)=>{
eSteemService.removeFavoriteUser(activeUsername(), username).then((resp) => {
$scope.visitorData.favorited = false;
$rootScope.$broadcast('favoritesChanged');
}).catch((e) => {
Expand Down
12 changes: 6 additions & 6 deletions src/services/steem-authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,12 @@ export default ($rootScope, steemApi, $q, cryptoService) => {

return {
follow: (following) => {
// requires Active or Owner key
// requires Posting key
const follower = $rootScope.user.username;

switch ($rootScope.user.type) {
case 's':
const wif = getProperWif(['active', 'owner']);
const wif = getProperWif(['posting']);
return follow(wif, follower, following);
break;
case 'sc':
Expand All @@ -818,12 +818,12 @@ export default ($rootScope, steemApi, $q, cryptoService) => {
}
},
unfollow: (following) => {
// requires Active or Owner key
// requires Posting key
const follower = $rootScope.user.username;

switch ($rootScope.user.type) {
case 's':
const wif = getProperWif(['active', 'owner']);
const wif = getProperWif(['posting']);
return unfollow(wif, follower, following);
break;
case 'sc':
Expand All @@ -833,12 +833,12 @@ export default ($rootScope, steemApi, $q, cryptoService) => {
}
},
mute: (following) => {
// requires Active or Owner key
// requires Posting key
const follower = $rootScope.user.username;

switch ($rootScope.user.type) {
case 's':
const wif = getProperWif(['active', 'owner']);
const wif = getProperWif(['posting']);
return ignore(wif, follower, following);
break;
case 'sc':
Expand Down

0 comments on commit e815047

Please sign in to comment.