diff options
author | HanYaodong <[email protected]> | 2024-03-09 23:38:09 +0800 |
---|---|---|
committer | HanYaodong <[email protected]> | 2024-03-09 23:42:17 +0800 |
commit | 25b53754bab47cee6d63ed58fa3ce2cbdf504c79 (patch) | |
tree | 0777141730d536343765b5ef65c4813be76088b7 /src/popup.ts | |
parent | 6c710363567e76dcfc58cc1189c18ab66968351c (diff) | |
download | SponsorBlock-25b53754bab47cee6d63ed58fa3ce2cbdf504c79.tar.gz SponsorBlock-25b53754bab47cee6d63ed58fa3ce2cbdf504c79.zip |
Stop refresh animation on popup when content script is not injected
Diffstat (limited to 'src/popup.ts')
-rw-r--r-- | src/popup.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/popup.ts b/src/popup.ts index f954f168..b986a2ed 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -15,6 +15,7 @@ import { Message, MessageResponse, PopupMessage, + RefreshSegmentsResponse, SponsorStartResponse, VoteResponse, } from "./messageTypes"; @@ -982,9 +983,17 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> { stopLoadingAnimation = AnimationUtils.applyLoadingAnimation(PageElements.refreshSegmentsButton, 0.3); } - function refreshSegments() { + async function refreshSegments() { startLoadingAnimation(); - sendTabMessage({ message: 'refreshSegments' }); + const response = await sendTabMessageAsync({ message: 'refreshSegments' }) as RefreshSegmentsResponse; + + if (response == null || !response.hasVideo) { + if (stopLoadingAnimation != null) { + stopLoadingAnimation(); + stopLoadingAnimation = null; + } + displayNoVideo(); + } } function skipSegment(actionType: ActionType, UUID: SegmentUUID, element?: HTMLElement): void { |