Skip to content

Commit

Permalink
Unload on API error
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleAM committed Aug 10, 2021
1 parent ff13c41 commit 0859c92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Content/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { emitHook } from 'src/Content/Global/Hooks';
import { MessageRenderer } from 'src/Content/Runtime/MessageRenderer';
import { API } from 'src/Global/API';
import { EmoteStore } from 'src/Global/EmoteStore';
import { asapScheduler, from, of, scheduled, Subject } from 'rxjs';
import { asapScheduler, from, iif, of, scheduled, Subject, throwError } from 'rxjs';
import { Logger } from 'src/Logger';
import { Twitch } from 'src/Page/Util/Twitch';
import { EmoteMenuButton } from 'src/Content/Components/EmoteMenu/EmoteMenuButton';
Expand Down Expand Up @@ -168,6 +168,10 @@ export class App implements Child.OnInjected, Child.OnAppLoaded {
concatAll(),
toArray(),
map(a => a.reduce((a, b) => a.concat(b as any))),
switchMap(e => iif(() => e.length === 0,
throwError(Error(`7TV failed to load (perhaps service is down?)`)),
of(e)
)),
map(e => emoteStore.enableSet(data.channelName, e)),
).subscribe({
next: (set: EmoteStore.EmoteSet) => {
Expand All @@ -177,6 +181,7 @@ export class App implements Child.OnInjected, Child.OnAppLoaded {
},
error(err) {
Logger.Get().error(`Failed to fetch current channel's emote set (${err}), the extension will be disabled`);
app?.sendMessageDown('SendSystemMessage', `Error: ${err.message}`);
}
});
}
Expand Down

0 comments on commit 0859c92

Please sign in to comment.