Skip to content

Commit

Permalink
Merge pull request #3537 from Bnyro/master
Browse files Browse the repository at this point in the history
feat: alert api error messages in feed and subscriptions
  • Loading branch information
Bnyro committed Apr 6, 2024
2 parents ef5bfae + 8548cf5 commit 7248dc7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/components/FeedPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ export default {
},
},
mounted() {
this.fetchFeed().then(videos => {
this.videosStore = videos;
this.fetchFeed().then(resp => {
if (resp.error) {
alert(resp.error);
return;
}
this.videosStore = resp;
this.loadMoreVideos();
this.updateWatched(this.videos);
});
Expand All @@ -118,26 +123,6 @@ export default {
window.removeEventListener("scroll", this.handleScroll);
},
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() {
const groups = await this.getChannelGroups();
this.channelGroups.push(...groups);
Expand Down
5 changes: 5 additions & 0 deletions src/components/SubscriptionsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ export default {
},
mounted() {
this.fetchSubscriptions().then(json => {
if (json.error) {
alert(json.error);
return;
}
this.subscriptions = json;
this.subscriptions.forEach(subscription => (subscription.subscribed = true));
});
Expand Down
20 changes: 20 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
download(text, filename, mimeType) {
var file = new Blob([text], { type: mimeType });
Expand Down

0 comments on commit 7248dc7

Please sign in to comment.