Skip to content

Commit c8f6402

Browse files
committed
Date modified and date created upon creation. Need to fix these attributes after snippet is edited in editor. After edited, date created disappears.
1 parent 183f989 commit c8f6402

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/CodeSnippetEditor.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export interface ICodeSnippetEditorMetadata {
4848
selectedTags: string[];
4949
allTags: string[];
5050
fromScratch: boolean;
51+
date_created: string;
52+
date_modified: string;
5153
}
5254

5355
export class CodeSnippetEditor extends ReactWidget {
@@ -389,6 +391,7 @@ export class CodeSnippetEditor extends ReactWidget {
389391
this._codeSnippetEditorMetaData.name = name;
390392
this._codeSnippetEditorMetaData.description = description;
391393
this._codeSnippetEditorMetaData.language = language;
394+
this._codeSnippetEditorMetaData.date_modified = new Date().toLocaleString();
392395

393396
const newPath =
394397
'snippets/' + this._codeSnippetEditorMetaData.name + '.json';
@@ -444,7 +447,9 @@ export class CodeSnippetEditor extends ReactWidget {
444447
language: this._codeSnippetEditorMetaData.language,
445448
code: this._codeSnippetEditorMetaData.code,
446449
id: this._codeSnippetEditorMetaData.id,
447-
tags: this._codeSnippetEditorMetaData.selectedTags
450+
tags: this._codeSnippetEditorMetaData.selectedTags,
451+
date_created: this._codeSnippetEditorMetaData.date_created,
452+
date_modified: this._codeSnippetEditorMetaData.date_modified
448453
})
449454
});
450455

src/CodeSnippetInputDialog.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export function CodeSnippetInputDialog(
9999
code: code,
100100
id: idx,
101101
tags: tags,
102-
date_created: new Date().toLocaleString()
102+
date_created: new Date().toLocaleString(),
103+
date_modified: new Date().toLocaleString()
103104
};
104105
const contentsService = CodeSnippetContentsService.getInstance();
105106
const currSnippets = codeSnippetWidget.codeSnippetWidgetModel.snippets;

0 commit comments

Comments
 (0)