@@ -35,10 +35,12 @@ const DB_LIST = 'databaseList';
3535export interface DatabaseOptions {
3636 displayName ?: string ;
3737 ignoreSourceArchive ?: boolean ;
38+ dateAdded ?: number | undefined ;
3839}
3940
4041interface FullDatabaseOptions extends DatabaseOptions {
4142 ignoreSourceArchive : boolean ;
43+ dateAdded : number | undefined ;
4244}
4345
4446interface PersistedDatabaseItem {
@@ -209,6 +211,12 @@ export interface DatabaseItem {
209211 * Will be `undefined` if the database is invalid. Can be updated by calling `refresh()`.
210212 */
211213 readonly contents : DatabaseContents | undefined ;
214+
215+ /**
216+ * The date this database was added as a unix timestamp. Or undefined if we don't know.
217+ */
218+ readonly dateAdded : number | undefined ;
219+
212220 /** If the database is invalid, describes why. */
213221 readonly error : Error | undefined ;
214222 /**
@@ -292,6 +300,10 @@ class DatabaseItemImpl implements DatabaseItem {
292300 return this . _contents ;
293301 }
294302
303+ public get dateAdded ( ) : number | undefined {
304+ return this . options . dateAdded ;
305+ }
306+
295307 public get error ( ) : Error | undefined {
296308 return this . _error ;
297309 }
@@ -466,8 +478,9 @@ export class DatabaseManager extends DisposableObject {
466478 this . loadPersistedState ( ) ; // Let this run async.
467479 }
468480
469- public async openDatabase ( uri : vscode . Uri , options ?: DatabaseOptions ) :
470- Promise < DatabaseItem > {
481+ public async openDatabase (
482+ uri : vscode . Uri , options ?: DatabaseOptions
483+ ) : Promise < DatabaseItem > {
471484
472485 const contents = await resolveDatabaseContents ( uri ) ;
473486 const realOptions = options || { } ;
@@ -476,7 +489,8 @@ export class DatabaseManager extends DisposableObject {
476489 const fullOptions : FullDatabaseOptions = {
477490 ignoreSourceArchive : ( realOptions . ignoreSourceArchive !== undefined ) ?
478491 realOptions . ignoreSourceArchive : isQLTestDatabase ,
479- displayName : realOptions . displayName
492+ displayName : realOptions . displayName ,
493+ dateAdded : realOptions . dateAdded || Date . now ( )
480494 } ;
481495 const databaseItem = new DatabaseItemImpl ( uri , contents , fullOptions , ( item ) => {
482496 this . _onDidChangeDatabaseItem . fire ( item ) ;
@@ -526,22 +540,28 @@ export class DatabaseManager extends DisposableObject {
526540 }
527541 }
528542
529- private async createDatabaseItemFromPersistedState ( state : PersistedDatabaseItem ) :
530- Promise < DatabaseItem > {
543+ private async createDatabaseItemFromPersistedState (
544+ state : PersistedDatabaseItem
545+ ) : Promise < DatabaseItem > {
531546
532547 let displayName : string | undefined = undefined ;
533548 let ignoreSourceArchive = false ;
549+ let dateAdded = undefined ;
534550 if ( state . options ) {
535551 if ( typeof state . options . displayName === 'string' ) {
536552 displayName = state . options . displayName ;
537553 }
538554 if ( typeof state . options . ignoreSourceArchive === 'boolean' ) {
539555 ignoreSourceArchive = state . options . ignoreSourceArchive ;
540556 }
557+ if ( typeof state . dateAdded === 'number' ) {
558+ dateAdded = state . dateAdded ;
559+ }
541560 }
542561 const fullOptions : FullDatabaseOptions = {
543- ignoreSourceArchive : ignoreSourceArchive ,
544- displayName : displayName
562+ ignoreSourceArchive,
563+ displayName,
564+ dateAdded
545565 } ;
546566 const item = new DatabaseItemImpl ( vscode . Uri . parse ( state . uri ) , undefined , fullOptions ,
547567 ( item ) => {
0 commit comments