From 63c2385644b59e314a67fe9a4d36dc1524f888ad Mon Sep 17 00:00:00 2001
From: Nicolas Constant
Date: Sat, 12 Sep 2020 14:01:35 -0400
Subject: [PATCH] added following functionality
---
.../thankyou-tutorial.component.html | 2 +-
.../thankyou-tutorial.component.scss | 14 ++++++++++-
.../thankyou-tutorial.component.ts | 25 ++++++++++++++++++-
src/app/services/tools.service.ts | 5 ++++
4 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.html b/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.html
index b434d986..9a2b72e1 100644
--- a/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.html
+++ b/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.html
@@ -12,7 +12,7 @@
-
+
Follow @Sengi_app
diff --git a/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.scss b/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.scss
index 8503012e..43200572 100644
--- a/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.scss
+++ b/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.scss
@@ -10,8 +10,20 @@
transition: all .2s;
box-shadow: inset 0 0 5px rgb(0, 84, 122);
- &:hover, &:focus {
+ &:hover,
+ &:focus {
text-decoration: none;
background-color: rgb(0, 84, 122);
}
+
+ &__disabled {
+ opacity: .15;
+ border: 1px solid gray;
+
+ &:hover,
+ &:focus {
+ text-decoration: none;
+ background-color: gray;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.ts b/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.ts
index a70f59c1..6f636013 100644
--- a/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.ts
+++ b/src/app/components/tutorial-enhanced/thankyou-tutorial/thankyou-tutorial.component.ts
@@ -1,18 +1,41 @@
import { Component, OnInit } from '@angular/core';
+import { ToolsService } from '../../../services/tools.service';
+import { MastodonWrapperService } from '../../../services/mastodon-wrapper.service';
+import { NotificationService } from '../../../services/notification.service';
+
@Component({
selector: 'app-thankyou-tutorial',
templateUrl: './thankyou-tutorial.component.html',
styleUrls: ['../tutorial-enhanced.component.scss', './thankyou-tutorial.component.scss']
})
export class ThankyouTutorialComponent implements OnInit {
+ followingDisabled: boolean;
- constructor() { }
+ constructor(
+ private readonly notificationService: NotificationService,
+ private readonly mastodonService: MastodonWrapperService,
+ private readonly toolsService: ToolsService) { }
ngOnInit() {
}
follow(): boolean {
+ if(this.followingDisabled) return;
+ this.followingDisabled = true;
+
+ const accounts = this.toolsService.getAllAccounts();
+ for (let acc of accounts) {
+ this.toolsService.findAccount(acc, "@sengi_app@mastodon.social")
+ .then(sengi => {
+ return this.mastodonService.follow(acc, sengi);
+ })
+ .catch(err => {
+ this.followingDisabled = false;
+ this.notificationService.notifyHttpError(err, acc);
+ });
+ }
+
return false;
}
}
diff --git a/src/app/services/tools.service.ts b/src/app/services/tools.service.ts
index 2e68a03f..001d9912 100644
--- a/src/app/services/tools.service.ts
+++ b/src/app/services/tools.service.ts
@@ -119,6 +119,11 @@ export class ToolsService {
return regAccounts.filter(x => x.isSelected);
}
+ getAllAccounts(): AccountInfo[] {
+ let regAccounts = this.store.snapshot().registeredaccounts.accounts;
+ return regAccounts;
+ }
+
getAccountById(accountId: string): AccountInfo {
let regAccounts = this.store.snapshot().registeredaccounts.accounts;
return regAccounts.find(x => x.id === accountId);