Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getReactionGroup } from './reactions/resource';
import { RemoteDb } from './persistence/remote-db';
import { v4 as uuidv4 } from 'uuid';
import { Deserializer } from './persistence/serialization/deserializer';
import { saveNotesToFile } from './persistence/local-db';

export const saveNoteComment = (
thread: vscode.CommentThread,
Expand Down Expand Up @@ -32,6 +33,7 @@ export const saveNoteComment = (
thread.contextValue = uuidv4();
noteMap.set(thread.contextValue, thread);
}
saveNotesToFile(noteMap);
if (remoteDb) {
remoteDb.pushNoteComment(thread, firstComment);
}
Expand Down Expand Up @@ -148,6 +150,8 @@ export const syncNoteMapWithRemote = (
remoteDb && remoteDb.pushNoteComment(localThread, true);
}
});

saveNotesToFile(noteMap);
};

export const getSetting = (settingName: string, defaultValue?: any) => {
Expand Down
2 changes: 2 additions & 0 deletions src/persistence/remote-db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as rethinkdb from 'rethinkdb';
import { Serializer } from '../serialization/serializer';
import { Deserializer } from '../serialization/deserializer';
import { readFileSync } from 'fs';
import { saveNotesToFile } from '../local-db';

export class RemoteDb {
private host: string;
Expand Down Expand Up @@ -134,6 +135,7 @@ export class RemoteDb {
newThread.contextValue ? newThread.contextValue : '',
newThread,
);
saveNotesToFile(this.noteMap);
vscode.window.showInformationMessage('Note received from remote DB.');
});
});
Expand Down
5 changes: 3 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import * as vscode from 'vscode';
import * as path from 'path';
import { platform } from 'os';
import { getSetting } from '../helpers';

export const isWindows = () => {
return platform() === 'win32';
Expand All @@ -26,7 +25,9 @@ export const getWorkspacePath = () => {
};

export const getLocalDbFilePath = () => {
const localDbFilePath = getSetting('localDatabase');
const localDbFilePath = vscode.workspace
.getConfiguration('security-notes')
.get<string>('localDatabase', '.security-notes.json');
if (path.isAbsolute(localDbFilePath)) {
return localDbFilePath;
} else {
Expand Down