forked from sickmartian/quick_simplenote
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
39 lines (28 loc) · 1.11 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import logging
import sublime
from ._config import CONFIG
from .lib.core import show_message, start
logger = logging.getLogger()
def reload_if_needed():
# global SIMPLENOTE_RELOAD_CALLS
# # Sublime calls this twice for some reason :(
# SIMPLENOTE_RELOAD_CALLS += 1
# logger.warning((SIMPLENOTE_RELOAD_CALLS, SIMPLENOTE_RELOAD_CALLS % 2))
# if SIMPLENOTE_RELOAD_CALLS % 2 != 0:
# logger.debug("Simplenote Reload call %s" % SIMPLENOTE_RELOAD_CALLS)
# return
settings = sublime.load_settings(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)
autostart = settings.get("autostart", True)
if not isinstance(autostart, bool):
show_message("`autostart` must be a boolean. Please check settings file.")
return
if autostart:
start()
def plugin_loaded():
# load_notes()
settings = sublime.load_settings(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)
settings.clear_on_change("username")
settings.clear_on_change("password")
settings.add_on_change("username", reload_if_needed)
settings.add_on_change("password", reload_if_needed)
reload_if_needed()