mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-21 21:29:20 +01:00
Don't reuse var for both timeout and interval
This commit is contained in:
parent
4ebfb544aa
commit
99ee6c3979
1 changed files with 3 additions and 2 deletions
|
@ -46,6 +46,7 @@ export default memo(function BackgroundService({ isLoggedIn }) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let sub;
|
let sub;
|
||||||
|
let streamTimeout;
|
||||||
let pollNotifications;
|
let pollNotifications;
|
||||||
if (isLoggedIn && visible) {
|
if (isLoggedIn && visible) {
|
||||||
const { masto, streaming, instance } = api();
|
const { masto, streaming, instance } = api();
|
||||||
|
@ -56,7 +57,7 @@ export default memo(function BackgroundService({ isLoggedIn }) {
|
||||||
let hasStreaming = false;
|
let hasStreaming = false;
|
||||||
// 2. Start streaming
|
// 2. Start streaming
|
||||||
if (streaming) {
|
if (streaming) {
|
||||||
pollNotifications = setTimeout(() => {
|
streamTimeout = setTimeout(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
hasStreaming = true;
|
hasStreaming = true;
|
||||||
|
@ -94,7 +95,7 @@ export default memo(function BackgroundService({ isLoggedIn }) {
|
||||||
return () => {
|
return () => {
|
||||||
sub?.unsubscribe?.();
|
sub?.unsubscribe?.();
|
||||||
sub = null;
|
sub = null;
|
||||||
clearTimeout(pollNotifications);
|
clearTimeout(streamTimeout);
|
||||||
clearInterval(pollNotifications);
|
clearInterval(pollNotifications);
|
||||||
};
|
};
|
||||||
}, [visible, isLoggedIn]);
|
}, [visible, isLoggedIn]);
|
||||||
|
|
Loading…
Reference in a new issue