feat: cancel media downloads on note change/exit

This commit is contained in:
thecodrr
2021-10-20 14:42:36 +05:00
parent 8b50a578ce
commit d4397fc4c1

View File

@@ -72,6 +72,7 @@ class EditorStore extends BaseStore {
const session = this.get().session;
if (session.id) await db.fs.cancel(session.id);
if (session.id === noteId && !force) return;
if (session.state === SESSION_STATES.unlocked) {
@@ -165,8 +166,11 @@ class EditorStore extends BaseStore {
});
};
newSession = (nonce) => {
newSession = async (nonce) => {
let context = noteStore.get().context;
const session = this.get().session;
if (session.id) await db.fs.cancel(session.id);
this.set((state) => {
state.session = {
...getDefaultSession(),
@@ -179,7 +183,10 @@ class EditorStore extends BaseStore {
appStore.setIsEditorOpen(true);
};
clearSession = (shouldNavigate = true) => {
clearSession = async (shouldNavigate = true) => {
const session = this.get().session;
if (session.id) await db.fs.cancel(session.id);
appStore.setIsEditorOpen(false);
this.set((state) => {
state.session = {