Commit 99f22baa authored by Odyseus's avatar Odyseus 🗯️
Browse files

0FeedsByJonbrettForkByOdyseus

- Modified applet initialization code in preparation for asynchronous settings initialization that will be available in the next Cinnamon version (4.2.x?).
parent 551bef15
Loading
Loading
Loading
Loading
+60 −35
Original line number Diff line number Diff line
@@ -52,19 +52,11 @@ FeedsReaderForkByOdyseus.prototype = {
        this.orientation = aOrientation;
        this.menu_keybinding_name = this.metadata.uuid + "-" + this.instance_id;

        try {
            this._bindSettings();

        this._initializeSettings(() => {
            this.logger = new $.Logger("FeedsReader", this.pref_enable_verbose_logging);

            this._expandAppletContextMenu();
            Gtk.IconTheme.get_default().append_search_path(this.metadata.path + "/icons/");
        } catch (aErr) {
            this.logger.error(aErr);
        }

        Mainloop.idle_add(() => {
            try {
        }, () => {
            this.open_menu = null;
            this.feed_queue = [];
            this.force_download = false;
@@ -93,16 +85,49 @@ FeedsReaderForkByOdyseus.prototype = {
                () => this._process_feeds());

            this.logger.debug("timer_id: " + this.timer_id);
        });
    },

    _initializeSettings: function(aDirectCallback, aIdleCallback) {
        this.settings = new Settings.AppletSettings(
            this,
            this.metadata.uuid,
            this.instance_id,
            true // Asynchronous settings initialization.
        );

        let callback = () => {
            try {
                this._bindSettings();
                aDirectCallback();
            } catch (aErr) {
                this.logger.error(aErr);
                global.logError(aErr);
            }

            Mainloop.idle_add(() => {
                try {
                    aIdleCallback();
                } catch (aErr) {
                    global.logError(aErr);
                }
            });
        };

        // Needed for retro-compatibility.
        // Mark for deletion on EOL. Cinnamon 4.2.x+
        // Always use promise. Declare content of callback variable
        // directly inside the promise callback.
        switch (this.settings.hasOwnProperty("promise")) {
            case true:
                this.settings.promise.then(() => callback());
                break;
            case false:
                callback();
                break;
        }
    },

    /* private function that connects to the settings-schema and initializes the variables */
    _bindSettings: function() {
        this.settings = new Settings.AppletSettings(this, this.metadata.uuid, this.instance_id);

        // Needed for retro-compatibility.
        // Mark for deletion on EOL. Cinnamon 3.2.x+
        let bD = {