only perform save all inside reload
This commit is contained in:
parent
55a0a3366b
commit
d85db1fd48
@ -6,6 +6,9 @@
|
|||||||
### Added
|
### Added
|
||||||
- Regex support for translation file patterns
|
- Regex support for translation file patterns
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Reload function internally consolidated
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Parsing for <kbd>.properties</kbd> files
|
- Parsing for <kbd>.properties</kbd> files
|
||||||
|
|
||||||
|
@ -49,9 +49,6 @@ public class DataStore {
|
|||||||
*/
|
*/
|
||||||
public void loadFromPersistenceLayer(@NotNull Consumer<Boolean> successResult) {
|
public void loadFromPersistenceLayer(@NotNull Consumer<Boolean> successResult) {
|
||||||
ProjectSettings settings = ProjectSettingsService.get(project).getState();
|
ProjectSettings settings = ProjectSettingsService.get(project).getState();
|
||||||
|
|
||||||
ApplicationManager.getApplication().saveAll(); // Save opened files (required if new locales were added)
|
|
||||||
|
|
||||||
ApplicationManager.getApplication().runReadAction(() -> {
|
ApplicationManager.getApplication().runReadAction(() -> {
|
||||||
try {
|
try {
|
||||||
this.data = new IOHandler(project, settings).read();
|
this.data = new IOHandler(project, settings).read();
|
||||||
|
@ -72,6 +72,7 @@ public class InstanceManager {
|
|||||||
* Fetches data from persistence layer and notifies all endpoints via {@link DataBus}.
|
* Fetches data from persistence layer and notifies all endpoints via {@link DataBus}.
|
||||||
*/
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
ApplicationManager.getApplication().saveAll(); // Save opened files (required if new locales were added)
|
||||||
store.loadFromPersistenceLayer((success) ->
|
store.loadFromPersistenceLayer((success) ->
|
||||||
bus.propagate().onUpdateData(store.getData()));
|
bus.propagate().onUpdateData(store.getData()));
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,7 @@ public class FileChangeListener implements AsyncFileListener {
|
|||||||
events.forEach((e) -> {
|
events.forEach((e) -> {
|
||||||
if(e.getPath().contains(localesPath)) { // Perform reload
|
if(e.getPath().contains(localesPath)) { // Perform reload
|
||||||
logger.debug("Detected file change. Reloading instance...");
|
logger.debug("Detected file change. Reloading instance...");
|
||||||
InstanceManager manager = InstanceManager.get(project);
|
InstanceManager.get(project).reload();
|
||||||
manager.store().loadFromPersistenceLayer((success) -> {
|
|
||||||
manager.bus().propagate().onUpdateData(manager.store().getData());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public abstract class EndToEndTestCase extends BasePlatformTestCase {
|
|||||||
|
|
||||||
public void testParseAndSerialize() throws IOException {
|
public void testParseAndSerialize() throws IOException {
|
||||||
// Read translation files based on the provided settings
|
// Read translation files based on the provided settings
|
||||||
InstanceManager.get(getProject()).reload();
|
InstanceManager.get(getProject()).store().loadFromPersistenceLayer(success -> {});
|
||||||
|
|
||||||
// Save the cached translation data to a temporary output directory
|
// Save the cached translation data to a temporary output directory
|
||||||
ProjectSettingsState out = new ProjectSettingsState(settings);
|
ProjectSettingsState out = new ProjectSettingsState(settings);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user