View Single Post
Old 02-24-2021, 03:16 AM   #366
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,203
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
You will need a custom template function to check for that. Taking a quick look at the view manager code, this can be easily done using this template:

Code:
from calibre_plugins.action_chains.templates import TemplateFunction

class ViewManagerLastVIew(TemplateFunction):

    name = 'view_manager_last_view'
    arg_count = 0

    def evaluate(self, formatter, kwargs, mi, locals):
        import calibre_plugins.view_manager.config as cfg
        gui = self.plugin_action.gui
        library_config = cfg.get_library_config(gui.current_db)
        return library_config.get(cfg.KEY_LAST_VIEW, '')
Copy/Paste the above code into the module manager. Now you can use this function in a condition as follows:

Code:
Template        : program: view_manager_last_view()
Datatype        : text
Comparison      : !=
Condition Value : On Device
However, your request uncovers another problem. When the conditions are not met, an error dialog will pop-up. This might not be suitable for events. I can turn this off for events and let it fail silently, or add an option in the conditions dialog to make the error dialog optional. Will think about it to see which of these two options is more suitable, and then add it later.

In the mean time, you can test the above to see whether it works.
capink is offline   Reply With Quote