mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	feat: alert api error messages in feed and subscriptions
This commit is contained in:
		
							parent
							
								
									3335b142e0
								
							
						
					
					
						commit
						8548cf5a4d
					
				
					 3 changed files with 32 additions and 22 deletions
				
			
		| 
						 | 
					@ -94,8 +94,13 @@ export default {
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
        this.fetchFeed().then(videos => {
 | 
					        this.fetchFeed().then(resp => {
 | 
				
			||||||
            this.videosStore = videos;
 | 
					            if (resp.error) {
 | 
				
			||||||
 | 
					                alert(resp.error);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            this.videosStore = resp;
 | 
				
			||||||
            this.loadMoreVideos();
 | 
					            this.loadMoreVideos();
 | 
				
			||||||
            this.updateWatched(this.videos);
 | 
					            this.updateWatched(this.videos);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
| 
						 | 
					@ -118,26 +123,6 @@ export default {
 | 
				
			||||||
        window.removeEventListener("scroll", this.handleScroll);
 | 
					        window.removeEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
        async fetchFeed() {
 | 
					 | 
				
			||||||
            if (this.authenticated) {
 | 
					 | 
				
			||||||
                return await this.fetchJson(this.authApiUrl() + "/feed", {
 | 
					 | 
				
			||||||
                    authToken: this.getAuthToken(),
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                const channels = this.getUnauthenticatedChannels();
 | 
					 | 
				
			||||||
                const split = channels.split(",");
 | 
					 | 
				
			||||||
                if (split.length > 100) {
 | 
					 | 
				
			||||||
                    return await this.fetchJson(this.authApiUrl() + "/feed/unauthenticated", null, {
 | 
					 | 
				
			||||||
                        method: "POST",
 | 
					 | 
				
			||||||
                        body: JSON.stringify(split),
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    return await this.fetchJson(this.authApiUrl() + "/feed/unauthenticated", {
 | 
					 | 
				
			||||||
                        channels: channels,
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        async loadChannelGroups() {
 | 
					        async loadChannelGroups() {
 | 
				
			||||||
            const groups = await this.getChannelGroups();
 | 
					            const groups = await this.getChannelGroups();
 | 
				
			||||||
            this.channelGroups.push(...groups);
 | 
					            this.channelGroups.push(...groups);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -143,6 +143,11 @@ export default {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
        this.fetchSubscriptions().then(json => {
 | 
					        this.fetchSubscriptions().then(json => {
 | 
				
			||||||
 | 
					            if (json.error) {
 | 
				
			||||||
 | 
					                alert(json.error);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.subscriptions = json;
 | 
					            this.subscriptions = json;
 | 
				
			||||||
            this.subscriptions.forEach(subscription => (subscription.subscribed = true));
 | 
					            this.subscriptions.forEach(subscription => (subscription.subscribed = true));
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										20
									
								
								src/main.js
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								src/main.js
									
										
									
									
									
								
							| 
						 | 
					@ -204,6 +204,26 @@ const mixin = {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        async fetchFeed() {
 | 
				
			||||||
 | 
					            if (this.authenticated) {
 | 
				
			||||||
 | 
					                return await this.fetchJson(this.authApiUrl() + "/feed", {
 | 
				
			||||||
 | 
					                    authToken: this.getAuthToken(),
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                const channels = this.getUnauthenticatedChannels();
 | 
				
			||||||
 | 
					                const split = channels.split(",");
 | 
				
			||||||
 | 
					                if (split.length > 100) {
 | 
				
			||||||
 | 
					                    return await this.fetchJson(this.authApiUrl() + "/feed/unauthenticated", null, {
 | 
				
			||||||
 | 
					                        method: "POST",
 | 
				
			||||||
 | 
					                        body: JSON.stringify(split),
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    return await this.fetchJson(this.authApiUrl() + "/feed/unauthenticated", {
 | 
				
			||||||
 | 
					                        channels: channels,
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
        /* generate a temporary file and ask the user to download it */
 | 
					        /* generate a temporary file and ask the user to download it */
 | 
				
			||||||
        download(text, filename, mimeType) {
 | 
					        download(text, filename, mimeType) {
 | 
				
			||||||
            var file = new Blob([text], { type: mimeType });
 | 
					            var file = new Blob([text], { type: mimeType });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue