From 58c4049d0943ce184065f1770c99541a35fb82fa Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Wed, 30 Dec 2020 15:43:59 +0100 Subject: [PATCH] Fixed race condition where the chat update function could not be used --- src/routes/_actions/timeline.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/routes/_actions/timeline.js b/src/routes/_actions/timeline.js index c502f3e6..eb9d7581 100644 --- a/src/routes/_actions/timeline.js +++ b/src/routes/_actions/timeline.js @@ -50,8 +50,15 @@ async function updateStatusAndThread (instanceName, accessToken, timelineName, s addStatusesOrNotifications(instanceName, timelineName, concat(context.ancestors, context.descendants)) } -if (window.fediloveFunctions !== undefined) - window.fediloveFunctions.updateStatusAndThread = updateStatusAndThread; +if (typeof window !== "undefined") { + const _this = setInterval(function() { + if (window.fediloveFunctions != undefined) { + window.fediloveFunctions.updateStatusAndThread = updateStatusAndThread; + clearInterval(_this); + } + }, 300); +} + async function fetchFreshThreadFromNetwork (instanceName, accessToken, statusId) { const [status, context] = await Promise.all([