Skip to content

Commit

Permalink
Add import/clean up events for fetchers
Browse files Browse the repository at this point in the history
And also flush the current library when a fetcher is spawned.
  • Loading branch information
welps authored and baskerville committed Aug 29, 2020
1 parent 2602842 commit ec844b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doc/HOOKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ Each event is a JSON object with a required `type` key:
```
// Display a notification message.
{"type": "notify", "message": STRING}
// Add a document to the DB. `info` is the camel cased JSON version
// Add a document to the current library. `info` is the camel cased JSON version
// of the `Info` structure defined in `src/metadata.rs`.
{"type": "addDocument", "info": OBJECT}
// Enable or disable the WiFi.
{"type": "setWifi", "enable": BOOL}
// Import new entries and update existing entries in the current library.
{"type": "import"}
// Remove entries with dangling paths from the current library.
{"type": "cleanUp"}
```

On *Plato*'s side, the events are read line by line, one event per line.
Expand Down
7 changes: 7 additions & 0 deletions src/view/home/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl Home {
let selected_library = context.settings.selected_library;
for hook in &context.settings.libraries[selected_library].hooks {
if context.library.home.join(&hook.path) == path {
context.library.flush();
self.insert_fetcher(hook, hub, context);
}
}
Expand Down Expand Up @@ -1121,6 +1122,12 @@ impl Home {
hub2.send(Event::SetWifi(enable)).ok();
}
},
Some("cleanUp") => {
hub2.send(Event::Select(EntryId::CleanUp)).ok();
},
Some("import") => {
hub2.send(Event::Select(EntryId::Import)).ok();
},
_ => (),
}
}
Expand Down

0 comments on commit ec844b5

Please sign in to comment.