mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 06:43:06 +02:00
Cache: Add API for looking a viewport up by a task it contains
This commit is contained in:
parent
ac9c44d118
commit
f79734aed9
1 changed files with 17 additions and 0 deletions
|
@ -65,6 +65,7 @@ class TaskCache(object):
|
|||
def __init__(self):
|
||||
self.task_cache = dict()
|
||||
self.vimwikitask_cache = dict()
|
||||
self.viewport_cache = dict()
|
||||
self.warriors = WarriorStore()
|
||||
self.buffer_has_authority = True
|
||||
|
||||
|
@ -159,6 +160,7 @@ class TaskCache(object):
|
|||
def reset(self):
|
||||
self.task_cache = dict()
|
||||
self.vimwikitask_cache = dict()
|
||||
self.viewport_cache = dict()
|
||||
|
||||
def load_vwtasks(self, buffer_has_authority=True):
|
||||
# Set the authority flag, which determines which data (Buffer or TW)
|
||||
|
@ -231,6 +233,21 @@ class TaskCache(object):
|
|||
port.load_tasks()
|
||||
port.sync_with_taskwarrior()
|
||||
|
||||
# Save the viewport in the cache
|
||||
self.viewport_cache[i] = port
|
||||
|
||||
def get_viewport_by_task(self, task):
|
||||
"""
|
||||
Looks for a viewport containing the given task by iterating over the cached
|
||||
items.
|
||||
|
||||
Returns the viewport, or None if not found.
|
||||
"""
|
||||
|
||||
for port in self.viewport_cache.values():
|
||||
if task in port.viewport_tasks:
|
||||
return port
|
||||
|
||||
def rebuild_vimwikitask_cache(self):
|
||||
new_cache = dict()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue