From c2094bd2c0a76a7b4509fae5c24edfd729d805de Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Thu, 9 Mar 2023 20:17:59 +0100
Subject: [PATCH] Show error message if TweetDuck features fail to load, for
 example due to TweetDeck Preview

Closes #356
---
 resources/Content/.all.js                                | 1 +
 resources/Content/tweetdeck/tweetdeck_preview_warning.js | 7 +++++++
 2 files changed, 8 insertions(+)
 create mode 100644 resources/Content/tweetdeck/tweetdeck_preview_warning.js

diff --git a/resources/Content/.all.js b/resources/Content/.all.js
index f6cc566d..edcaa3d6 100644
--- a/resources/Content/.all.js
+++ b/resources/Content/.all.js
@@ -67,6 +67,7 @@ import setup_tweet_context_menu from "./tweetdeck/setup_tweet_context_menu.js";
 import setup_tweetduck_account_bamboozle from "./tweetdeck/setup_tweetduck_account_bamboozle.js";
 import setup_video_player from "./tweetdeck/setup_video_player.js";
 import skip_pre_login_page from "./tweetdeck/skip_pre_login_page.js";
+import tweetdeck_preview_warning from "./tweetdeck/tweetdeck_preview_warning.js";
 import update from "./update/update.js";
 
 const globalFunctions = [
diff --git a/resources/Content/tweetdeck/tweetdeck_preview_warning.js b/resources/Content/tweetdeck/tweetdeck_preview_warning.js
new file mode 100644
index 00000000..032eecc2
--- /dev/null
+++ b/resources/Content/tweetdeck/tweetdeck_preview_warning.js
@@ -0,0 +1,7 @@
+import { $TD } from "../api/bridge.js";
+
+export default function() {
+	if (!("TD" in window)) {
+		$TD.alert("warning", "Some TweetDuck features failed to load. This might happen if your Twitter account is enrolled into the TweetDeck Preview, which TweetDuck does not support. Try opting out of the TweetDeck Preview to restore TweetDuck's functionality.");
+	}
+}