aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-user-subscription
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-17 14:42:53 +0200
committerChocobozzz <me@florianbigard.com>2021-08-18 08:35:06 +0200
commit9df52d660feb722404be00a50f3c8a612bec1c15 (patch)
treedde52880fa012874d24c60f64eb596b0a789cc8b /client/src/app/shared/shared-user-subscription
parentadb8809d43648ea0a64d6845bb39aa3bd0e005a6 (diff)
downloadPeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.gz
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.zst
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.zip
Migrate client to eslint
Diffstat (limited to 'client/src/app/shared/shared-user-subscription')
-rw-r--r--client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts16
-rw-r--r--client/src/app/shared/shared-user-subscription/subscribe-button.component.ts4
-rw-r--r--client/src/app/shared/shared-user-subscription/user-subscription.service.ts20
3 files changed, 22 insertions, 18 deletions
diff --git a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
index 666199523..a951134eb 100644
--- a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
+++ b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
@@ -6,7 +6,7 @@ import { USER_HANDLE_VALIDATOR } from '../form-validators/user-validators'
6@Component({ 6@Component({
7 selector: 'my-remote-subscribe', 7 selector: 'my-remote-subscribe',
8 templateUrl: './remote-subscribe.component.html', 8 templateUrl: './remote-subscribe.component.html',
9 styleUrls: ['./remote-subscribe.component.scss'] 9 styleUrls: [ './remote-subscribe.component.scss' ]
10}) 10})
11export class RemoteSubscribeComponent extends FormReactive implements OnInit { 11export class RemoteSubscribeComponent extends FormReactive implements OnInit {
12 @Input() uri: string 12 @Input() uri: string
@@ -42,17 +42,21 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit {
42 // Should not have CORS error because https://tools.ietf.org/html/rfc7033#section-5 42 // Should not have CORS error because https://tools.ietf.org/html/rfc7033#section-5
43 fetch(`${protocol}//${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) 43 fetch(`${protocol}//${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`)
44 .then(response => response.json()) 44 .then(response => response.json())
45 .then(data => new Promise((res, rej) => { 45 .then(data => {
46 if (!data || Array.isArray(data.links) === false) return rej() 46 if (!data || Array.isArray(data.links) === false) {
47 throw new Error('Not links in webfinger response')
48 }
47 49
48 const link: { template: string } = data.links.find((link: any) => { 50 const link: { template: string } = data.links.find((link: any) => {
49 return link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe' 51 return link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe'
50 }) 52 })
51 53
52 if (link && link.template.includes('{uri}')) { 54 if (link?.template.includes('{uri}')) {
53 res(link.template.replace('{uri}', encodeURIComponent(this.uri))) 55 return link.template.replace('{uri}', encodeURIComponent(this.uri))
54 } 56 }
55 })) 57
58 throw new Error('No subscribe template in webfinger response')
59 })
56 .then(window.open) 60 .then(window.open)
57 .catch(err => { 61 .catch(err => {
58 console.error(err) 62 console.error(err)
diff --git a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts
index 796493bd9..180bc0565 100644
--- a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts
+++ b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts
@@ -137,7 +137,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges {
137 this.notifier.success( 137 this.notifier.success(
138 this.account 138 this.account
139 ? $localize`Unsubscribed from all channels of ${this.account.nameWithHost}` 139 ? $localize`Unsubscribed from all channels of ${this.account.nameWithHost}`
140 : $localize`Unsubscribed from ${this.videoChannels[ 0 ].nameWithHost}`, 140 : $localize`Unsubscribed from ${this.videoChannels[0].nameWithHost}`,
141 141
142 $localize`Unsubscribed` 142 $localize`Unsubscribed`
143 ) 143 )
@@ -157,7 +157,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges {
157 157
158 subscribeStatus (subscribed: boolean) { 158 subscribeStatus (subscribed: boolean) {
159 const accumulator: string[] = [] 159 const accumulator: string[] = []
160 for (const [key, value] of this.subscribed.entries()) { 160 for (const [ key, value ] of this.subscribed.entries()) {
161 if (value === subscribed) accumulator.push(key) 161 if (value === subscribed) accumulator.push(key)
162 } 162 }
163 163
diff --git a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
index bb44660d2..e4fc09b36 100644
--- a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
+++ b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
@@ -46,8 +46,8 @@ export class UserSubscriptionService {
46 } 46 }
47 47
48 getUserSubscriptionVideos (parameters: { 48 getUserSubscriptionVideos (parameters: {
49 videoPagination: ComponentPaginationLight, 49 videoPagination: ComponentPaginationLight
50 sort: VideoSortField, 50 sort: VideoSortField
51 skipCount?: boolean 51 skipCount?: boolean
52 }): Observable<ResultList<Video>> { 52 }): Observable<ResultList<Video>> {
53 const { videoPagination, sort, skipCount } = parameters 53 const { videoPagination, sort, skipCount } = parameters
@@ -131,16 +131,16 @@ export class UserSubscriptionService {
131 131
132 listenToSubscriptionCacheChange (nameWithHost: string) { 132 listenToSubscriptionCacheChange (nameWithHost: string) {
133 if (nameWithHost in this.myAccountSubscriptionCacheObservable) { 133 if (nameWithHost in this.myAccountSubscriptionCacheObservable) {
134 return this.myAccountSubscriptionCacheObservable[ nameWithHost ] 134 return this.myAccountSubscriptionCacheObservable[nameWithHost]
135 } 135 }
136 136
137 const obs = this.existsObservable 137 const obs = this.existsObservable
138 .pipe( 138 .pipe(
139 filter(existsResult => existsResult[ nameWithHost ] !== undefined), 139 filter(existsResult => existsResult[nameWithHost] !== undefined),
140 map(existsResult => existsResult[ nameWithHost ]) 140 map(existsResult => existsResult[nameWithHost])
141 ) 141 )
142 142
143 this.myAccountSubscriptionCacheObservable[ nameWithHost ] = obs 143 this.myAccountSubscriptionCacheObservable[nameWithHost] = obs
144 return obs 144 return obs
145 } 145 }
146 146
@@ -150,16 +150,16 @@ export class UserSubscriptionService {
150 if (nameWithHost in this.myAccountSubscriptionCache) { 150 if (nameWithHost in this.myAccountSubscriptionCache) {
151 logger('Found cache for %d.', nameWithHost) 151 logger('Found cache for %d.', nameWithHost)
152 152
153 return of(this.myAccountSubscriptionCache[ nameWithHost ]) 153 return of(this.myAccountSubscriptionCache[nameWithHost])
154 } 154 }
155 155
156 this.existsSubject.next(nameWithHost) 156 this.existsSubject.next(nameWithHost)
157 157
158 logger('Fetching from network for %d.', nameWithHost) 158 logger('Fetching from network for %d.', nameWithHost)
159 return this.existsObservable.pipe( 159 return this.existsObservable.pipe(
160 filter(existsResult => existsResult[ nameWithHost ] !== undefined), 160 filter(existsResult => existsResult[nameWithHost] !== undefined),
161 map(existsResult => existsResult[ nameWithHost ]), 161 map(existsResult => existsResult[nameWithHost]),
162 tap(result => this.myAccountSubscriptionCache[ nameWithHost ] = result) 162 tap(result => this.myAccountSubscriptionCache[nameWithHost] = result)
163 ) 163 )
164 } 164 }
165 165