fix: GroupBySource not updated on template edit
This commit is contained in:
@@ -22,6 +22,11 @@ class GroupBy:
|
|||||||
self._watcher = [] # type: List[Watcher]
|
self._watcher = [] # type: List[Watcher]
|
||||||
self._results = [] # type: List[GroupBySource]
|
self._results = [] # type: List[GroupBySource]
|
||||||
self.resolver = resolver
|
self.resolver = resolver
|
||||||
|
self.didBuild = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def isNew(self) -> bool:
|
||||||
|
return not self.didBuild
|
||||||
|
|
||||||
def add_watcher(self, key: str, config: 'AnyConfig') -> Watcher:
|
def add_watcher(self, key: str, config: 'AnyConfig') -> Watcher:
|
||||||
''' Init Config and add to watch list. '''
|
''' Init Config and add to watch list. '''
|
||||||
@@ -60,6 +65,7 @@ class GroupBy:
|
|||||||
|
|
||||||
def make_once(self, builder: 'Builder') -> None:
|
def make_once(self, builder: 'Builder') -> None:
|
||||||
''' Perform groupby, iter over sources with watcher callback. '''
|
''' Perform groupby, iter over sources with watcher callback. '''
|
||||||
|
self.didBuild = True
|
||||||
if self._watcher:
|
if self._watcher:
|
||||||
self.resolver.reset()
|
self.resolver.reset()
|
||||||
for w in self._watcher:
|
for w in self._watcher:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from lektor.db import Page # isinstance
|
from lektor.assets import File, Directory # isinstance
|
||||||
from lektor.pluginsystem import Plugin # subclass
|
from lektor.pluginsystem import Plugin # subclass
|
||||||
from typing import TYPE_CHECKING, Iterator, Any
|
from typing import TYPE_CHECKING, Iterator, Any
|
||||||
from .backref import GroupByRef, VGroups
|
from .backref import GroupByRef, VGroups
|
||||||
@@ -27,8 +27,11 @@ class GroupByPlugin(Plugin):
|
|||||||
) -> None:
|
) -> None:
|
||||||
# before-build may be called before before-build-all (issue #1017)
|
# before-build may be called before before-build-all (issue #1017)
|
||||||
# make sure it is always evaluated first
|
# make sure it is always evaluated first
|
||||||
if isinstance(source, Page):
|
if isinstance(source, (File, Directory)):
|
||||||
self._init_once(builder)
|
return
|
||||||
|
groupby = self._init_once(builder)
|
||||||
|
if groupby.isNew and isinstance(source, GroupBySource):
|
||||||
|
self.has_changes = True
|
||||||
|
|
||||||
def on_after_build(self, build_state: 'BuildState', **extra: Any) -> None:
|
def on_after_build(self, build_state: 'BuildState', **extra: Any) -> None:
|
||||||
if build_state.updated_artifacts:
|
if build_state.updated_artifacts:
|
||||||
|
|||||||
Reference in New Issue
Block a user