mirror of
https://github.com/silvanocerza/github-gitless-sync.git
synced 2026-07-22 12:10:28 +00:00
Add method to flush file events
This commit is contained in:
parent
16459572a0
commit
7787a6f23b
2 changed files with 19 additions and 0 deletions
|
|
@ -21,6 +21,13 @@ export default class EventsHandler {
|
|||
this.vault.on("rename", this.onRename.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns and empties the events queue.
|
||||
*/
|
||||
flush(): Event[] {
|
||||
return this.eventsQueue.flush();
|
||||
}
|
||||
|
||||
private async onCreate(file: TAbstractFile) {
|
||||
if (!file.path.startsWith(this.localContentDir)) {
|
||||
// The file has not been created in directory that we're syncing with GitHub
|
||||
|
|
|
|||
|
|
@ -44,4 +44,16 @@ export default class EventsQueue {
|
|||
this.eventsQueue.set(event.filePath, event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns and empties the events queue.
|
||||
*/
|
||||
flush(): Event[] {
|
||||
const events: Event[] = [];
|
||||
this.eventsQueue.forEach((event) => {
|
||||
events.push(event);
|
||||
});
|
||||
this.eventsQueue.clear();
|
||||
return events;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue