1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-07 08:34:06 +02:00

Improve resistance to errors in bootstrapping script and modules

This commit is contained in:
chylex 2021-12-22 08:47:17 +01:00
parent e854315a81
commit fd634379d7
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
5 changed files with 27 additions and 7 deletions

View File

@ -43,6 +43,7 @@ import pin_composer_icon from "./tweetdeck/pin_composer_icon.js";
import ready_plugins from "./tweetdeck/ready_plugins.js";
import register_composer_active_event from "./tweetdeck/register_composer_active_event.js";
import register_global_functions from "./tweetdeck/register_global_functions.js";
import register_global_functions_jquery from "./tweetdeck/register_global_functions_jquery.js";
import restore_cleared_column from "./tweetdeck/restore_cleared_column.js";
import screenshot_tweet from "./tweetdeck/screenshot_tweet.js";
import setup_column_type_attributes from "./tweetdeck/setup_column_type_attributes.js";

View File

@ -36,13 +36,21 @@
return [ successes, modules.length ];
}
function notifyModulesLoaded(obj) {
try {
obj.onModulesLoaded(namespace);
} catch (e) {
console.error(`${tag} Error in post-load notification: ${e}`);
}
}
loadModules().then(([ successes, total ]) => {
if ("$TD" in window) {
window.$TD.onModulesLoaded(namespace);
notifyModulesLoaded(window.$TD);
}
if ("TD_PLUGINS" in window) {
window.TD_PLUGINS.onModulesLoaded(namespace);
notifyModulesLoaded(window.TD_PLUGINS);
}
console.info(`${tag} Successfully loaded ${successes} / ${total} module(s).`);

View File

@ -2,20 +2,18 @@ import { registerPropertyUpdateCallback, triggerPropertiesUpdated } from "../api
import { applyROT13 } from "./globals/apply_rot13.js";
import { getColumnName } from "./globals/get_column_name.js";
import { injectMustache } from "./globals/inject_mustache.js";
import { prioritizeNewestEvent } from "./globals/prioritize_newest_event.js";
import { reloadBrowser } from "./globals/reload_browser.js";
import { reloadColumns } from "./globals/reload_columns.js";
import { showTweetDetail } from "./globals/show_tweet_detail.js";
/**
* Registers global functions which do not require jQuery.
*/
export default function() {
window.jQuery = window.$;
window.TDGF_applyROT13 = applyROT13;
window.TDGF_getColumnName = getColumnName;
window.TDGF_injectMustache = injectMustache;
window.TDGF_onPropertiesUpdated = triggerPropertiesUpdated;
window.TDGF_prioritizeNewestEvent = prioritizeNewestEvent;
window.TDGF_registerPropertyUpdateCallback = registerPropertyUpdateCallback;
window.TDGF_reload = reloadBrowser;
window.TDGF_reloadColumns = reloadColumns;
window.TDGF_showTweetDetail = showTweetDetail;
};

View File

@ -0,0 +1,12 @@
import { $ } from "../api/jquery.js";
import { prioritizeNewestEvent } from "./globals/prioritize_newest_event.js";
import { showTweetDetail } from "./globals/show_tweet_detail.js";
/**
* Registers global functions which require jQuery.
*/
export default function() {
window.jQuery = $;
window.TDGF_prioritizeNewestEvent = prioritizeNewestEvent;
window.TDGF_showTweetDetail = showTweetDetail;
};

View File

@ -444,6 +444,7 @@
<Content Include="Resources\Content\tweetdeck\ready_plugins.js" />
<Content Include="Resources\Content\tweetdeck\register_composer_active_event.js" />
<Content Include="Resources\Content\tweetdeck\register_global_functions.js" />
<Content Include="Resources\Content\tweetdeck\register_global_functions_jquery.js" />
<Content Include="Resources\Content\tweetdeck\restore_cleared_column.js" />
<Content Include="Resources\Content\tweetdeck\screenshot_tweet.js" />
<Content Include="Resources\Content\tweetdeck\setup_column_type_attributes.js" />