forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.ts
More file actions
25 lines (22 loc) · 954 Bytes
/
common.ts
File metadata and controls
25 lines (22 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { Memento } from 'vscode';
import { noop } from '../common/utils/misc';
import { Settings } from './constants';
export function getSavedUriList(globalState: Memento): { uri: string; time: number }[] {
const uriList = globalState.get<{ uri: string; time: number }[]>(Settings.JupyterServerUriList);
return uriList
? uriList.sort((a, b) => {
return b.time - a.time;
})
: [];
}
export function addToUriList(globalState: Memento, uri: string, time: number) {
const uriList = getSavedUriList(globalState);
const editList = uriList.filter((f, i) => {
return f.uri !== uri && i < Settings.JupyterServerUriListMax - 1;
});
editList.splice(0, 0, { uri, time });
globalState.update(Settings.JupyterServerUriList, editList).then(noop, noop);
}