Compare commits
3 Commits
702e4daa44
...
bd75317417
Author | SHA1 | Date |
---|---|---|
Nicolas Constant | bd75317417 | |
Nicolas Constant | 74eed7e8ba | |
Nicolas Constant | ebce6282c5 |
|
@ -127,6 +127,13 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
|||
|
||||
// this.statusStateService.setStatusContent(this.status, this.statusReplyingToWrapper);
|
||||
|
||||
// Retrieve mentions
|
||||
for(let mention of value.status.mentions){
|
||||
if(this.status){
|
||||
this.status = this.status.replace(`@${mention.username}`, `@${mention.acct}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.setVisibilityFromStatus(value.status);
|
||||
this.title = value.status.spoiler_text;
|
||||
this.statusLoaded = true;
|
||||
|
|
|
@ -45,7 +45,15 @@ export class PollComponent implements OnInit {
|
|||
}
|
||||
|
||||
this.options.length = 0;
|
||||
const maxVotes = Math.max(...this.poll.options.map(x => x.votes_count));
|
||||
|
||||
let maxVotes = Math.max(...this.poll.options.map(x => x.votes_count));
|
||||
|
||||
if(!this.poll.multiple){ //Fix for absurd values in pleroma
|
||||
this.poll.voters_count = this.poll.votes_count;
|
||||
} else if(this.poll.voters_count * this.poll.options.length < this.poll.votes_count){
|
||||
this.poll.voters_count = this.poll.votes_count;
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
for (let opt of this.poll.options) {
|
||||
let optWrapper = new PollOptionWrapper(i, opt, this.poll.votes_count, this.poll.voters_count, opt.votes_count === maxVotes);
|
||||
|
@ -195,7 +203,7 @@ class PollOptionWrapper implements PollOption {
|
|||
if (totalVotes === 0) {
|
||||
this.percentage = '0';
|
||||
} else {
|
||||
this.percentage = ((this.votes_count / votesDivider) * 100).toFixed(0);
|
||||
this.percentage = ((this.votes_count / votesDivider) * 100).toFixed(0);
|
||||
}
|
||||
this.isMax = isMax;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Store } from '@ngxs/store';
|
|||
|
||||
import { Account, Status, Relationship, Attachment } from "../../../services/models/mastodon.interfaces";
|
||||
import { MastodonWrapperService } from '../../../services/mastodon-wrapper.service';
|
||||
import { ToolsService, OpenThreadEvent } from '../../../services/tools.service';
|
||||
import { ToolsService, OpenThreadEvent, InstanceType } from '../../../services/tools.service';
|
||||
import { NotificationService } from '../../../services/notification.service';
|
||||
import { AccountInfo } from '../../../states/accounts.state';
|
||||
import { StatusWrapper, OpenMediaEvent } from '../../../models/common.model';
|
||||
|
@ -286,21 +286,44 @@ export class UserProfileComponent extends BrowseBase {
|
|||
}
|
||||
|
||||
follow(): boolean {
|
||||
this.loadingRelationShip = true;
|
||||
|
||||
const userAccount = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
let foundAccountToFollow: Account;
|
||||
this.toolsService.findAccount(userAccount, this.lastAccountName)
|
||||
.then((account: Account) => {
|
||||
foundAccountToFollow = account;
|
||||
return this.mastodonService.follow(userAccount, account);
|
||||
})
|
||||
.then((relationship: Relationship) => {
|
||||
this.relationship = relationship;
|
||||
this.relationship = relationship;
|
||||
})
|
||||
.then(async () => {
|
||||
// Double check for pleroma users
|
||||
const instanceInfo = await this.toolsService.getInstanceInfo(userAccount);
|
||||
if(instanceInfo.type === InstanceType.Pleroma || instanceInfo.type === InstanceType.Akkoma){
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
|
||||
const relationships = await this.mastodonService.getRelationships(userAccount, [foundAccountToFollow]);
|
||||
const relationship = relationships.find(x => x.id === foundAccountToFollow.id);
|
||||
if(relationship){
|
||||
this.relationship = relationship;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err: HttpErrorResponse) => {
|
||||
this.notificationService.notifyHttpError(err, userAccount);
|
||||
})
|
||||
.then(() => {
|
||||
this.loadingRelationShip = false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
unfollow(): boolean {
|
||||
this.loadingRelationShip = true;
|
||||
|
||||
const userAccount = this.toolsService.getSelectedAccounts()[0];
|
||||
this.toolsService.findAccount(userAccount, this.lastAccountName)
|
||||
.then((account: Account) => {
|
||||
|
@ -311,6 +334,9 @@ export class UserProfileComponent extends BrowseBase {
|
|||
})
|
||||
.catch((err: HttpErrorResponse) => {
|
||||
this.notificationService.notifyHttpError(err, userAccount);
|
||||
})
|
||||
.then(() => {
|
||||
this.loadingRelationShip = false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue