Pārlūkot izejas kodu

Adds synced keys to avoid welcome/upgrade on sync

main
Eric Amodio pirms 4 gadiem
vecāks
revīzija
2958116b97
4 mainītis faili ar 34 papildinājumiem un 14 dzēšanām
  1. +3
    -3
      src/commands/closeView.ts
  2. +2
    -2
      src/commands/showView.ts
  3. +8
    -3
      src/constants.ts
  4. +21
    -6
      src/extension.ts

+ 3
- 3
src/commands/closeView.ts Parādīt failu

@ -1,6 +1,6 @@
'use strict';
import { command, Command, CommandContext, Commands } from './common';
import { ContextKeys, GlobalState, setContext } from '../constants';
import { ContextKeys, setContext, SyncedState } from '../constants';
import { Container } from '../container';
@command()
@ -16,11 +16,11 @@ export class CloseViewCommand extends Command {
async execute(command: Commands) {
switch (command) {
case Commands.CloseWelcomeView:
await Container.context.globalState.update(GlobalState.WelcomeViewVisible, false);
await Container.context.globalState.update(SyncedState.WelcomeViewVisible, false);
await setContext(ContextKeys.ViewsWelcomeVisible, false);
break;
case Commands.CloseUpdatesView:
await Container.context.globalState.update(GlobalState.UpdatesViewVisible, false);
await Container.context.globalState.update(SyncedState.UpdatesViewVisible, false);
await setContext(ContextKeys.ViewsUpdatesVisible, false);
break;
}

+ 2
- 2
src/commands/showView.ts Parādīt failu

@ -2,7 +2,7 @@
import { commands } from 'vscode';
import { command, Command, CommandContext, Commands } from './common';
import { configuration } from '../configuration';
import { ContextKeys, GlobalState, setContext } from '../constants';
import { ContextKeys, setContext, SyncedState } from '../constants';
import { Container } from '../container';
@command()
@ -57,7 +57,7 @@ export class ShowViewCommand extends Command {
return Container.tagsView.show();
case Commands.ShowWelcomeView:
await setContext(ContextKeys.ViewsWelcomeVisible, true);
void Container.context.globalState.update(GlobalState.WelcomeViewVisible, true);
void Container.context.globalState.update(SyncedState.WelcomeViewVisible, true);
void (await commands.executeCommand('gitlens.views.welcome.focus'));
}

+ 8
- 3
src/constants.ts Parādīt failu

@ -134,12 +134,17 @@ export enum GlyphChars {
ZeroWidthSpace = '\u200b',
}
export enum SyncedState {
Version = 'gitlens:synced:version',
UpdatesViewVisible = 'gitlens:views:updates:visible',
WelcomeViewVisible = 'gitlens:views:welcome:visible',
}
export enum GlobalState {
DeprecatedVersion = 'gitlensVersion',
Avatars = 'gitlens:avatars',
DisallowConnectionPrefix = 'gitlens:disallow:connection:',
Version = 'gitlensVersion',
UpdatesViewVisible = 'gitlens:views:updates:visible',
WelcomeViewVisible = 'gitlens:views:welcome:visible',
Version = 'gitlens:version',
}
export const ImageMimetypes: Record<string, string> = {

+ 21
- 6
src/extension.ts Parādīt failu

@ -2,14 +2,14 @@
import { commands, ExtensionContext, extensions, window, workspace } from 'vscode';
import { Commands, registerCommands } from './commands';
import { configuration, Configuration } from './configuration';
import { ContextKeys, extensionQualifiedId, GlobalState, GlyphChars, setContext } from './constants';
import { ContextKeys, extensionQualifiedId, GlobalState, GlyphChars, setContext, SyncedState } from './constants';
import { Container } from './container';
import { Git, GitCommit } from './git/git';
import { GitService } from './git/gitService';
import { GitUri } from './git/gitUri';
import { Logger } from './logger';
import { Messages } from './messages';
import { Strings } from './system';
import { Strings, Versions } from './system';
import { ViewNode } from './views/nodes';
export async function activate(context: ExtensionContext) {
@ -18,20 +18,24 @@ export async function activate(context: ExtensionContext) {
// Pretend we are enabled (until we know otherwise) and set the view contexts to reduce flashing on load
void setContext(ContextKeys.Enabled, true);
const previousVersion = context.globalState.get<string>(GlobalState.Version);
const syncedVersion = context.globalState.get<string>(SyncedState.Version);
const previousVersion =
context.globalState.get<string>(GlobalState.Version) ??
context.globalState.get<string>(GlobalState.DeprecatedVersion) ??
syncedVersion;
if (previousVersion == null) {
void context.globalState.update(GlobalState.WelcomeViewVisible, true);
void context.globalState.update(SyncedState.WelcomeViewVisible, true);
void setContext(ContextKeys.ViewsWelcomeVisible, true);
void setContext(ContextKeys.ViewsUpdatesVisible, false);
} else {
void setContext(
ContextKeys.ViewsWelcomeVisible,
context.globalState.get(GlobalState.WelcomeViewVisible) ?? false,
context.globalState.get(SyncedState.WelcomeViewVisible) ?? false,
);
void setContext(
ContextKeys.ViewsUpdatesVisible,
context.globalState.get(GlobalState.UpdatesViewVisible) !== false,
context.globalState.get(SyncedState.UpdatesViewVisible) !== false,
);
}
@ -97,8 +101,19 @@ export async function activate(context: ExtensionContext) {
notifyOnUnsupportedGitVersion(gitVersion);
void showWelcomeOrWhatsNew(gitlensVersion, previousVersion);
context.globalState.setKeysForSync([
SyncedState.Version,
SyncedState.UpdatesViewVisible,
SyncedState.WelcomeViewVisible,
]);
void context.globalState.update(GlobalState.Version, gitlensVersion);
// Only update our synced version if the new version is greater
if (syncedVersion == null || Versions.compare(gitlensVersion, syncedVersion) === 1) {
void context.globalState.update(SyncedState.Version, gitlensVersion);
}
Logger.log(
`GitLens (v${gitlensVersion}${cfg.mode.active ? `, mode: ${cfg.mode.active}` : ''}) activated ${
GlyphChars.Dot

Notiek ielāde…
Atcelt
Saglabāt