提交 c4c28aea 编写于 作者: J Joao Moreno

Merge branch 'olingern/cache-release-notes' of...

Merge branch 'olingern/cache-release-notes' of https://github.com/olingern/vscode into olingern-olingern/cache-release-notes
......@@ -45,6 +45,8 @@ const NotNowAction = new Action(
() => TPromise.as(true)
);
let releaseNotesCache: Object = {};
export function loadReleaseNotes(accessor: ServicesAccessor, version: string): TPromise<string> {
const requestService = accessor.get(IRequestService);
const keybindingService = accessor.get(IKeybindingService);
......@@ -59,6 +61,17 @@ export function loadReleaseNotes(accessor: ServicesAccessor, version: string): T
const url = `${baseUrl}/v${versionLabel}.md`;
const unassigned = nls.localize('unassigned', "unassigned");
const storeReleaseNotes = (text: string): TPromise<string> => {
releaseNotesCache[version] = text;
return new TPromise<string>((c, e) => c(releaseNotesCache[version]));
};
const getReleaseNotes = (): TPromise<string> => {
return new TPromise<string>((c, e) => {
c(releaseNotesCache[version]);
});
};
const patchKeybindings = (text: string): string => {
const kb = (match: string, kb: string) => {
const keybinding = keybindingService.lookupKeybindings(kb)[0];
......@@ -91,9 +104,14 @@ export function loadReleaseNotes(accessor: ServicesAccessor, version: string): T
.replace(/kbstyle\(([^\)]+)\)/gi, kbstyle);
};
return requestService.request({ url })
.then(asText)
.then(text => patchKeybindings(text));
if (releaseNotesCache[version]) {
return getReleaseNotes()
.then(text => patchKeybindings(text));
} else {
return requestService.request({ url })
.then(asText)
.then(text => storeReleaseNotes(patchKeybindings(text)));
}
}
export class OpenLatestReleaseNotesInBrowserAction extends Action {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册