Browse Source

Uses updateRecordValue

main
Eric Amodio 2 years ago
parent
commit
58a99ccd0a
2 changed files with 4 additions and 22 deletions
  1. +2
    -11
      src/git/models/repository.ts
  2. +2
    -11
      src/views/searchAndCompareView.ts

+ 2
- 11
src/git/models/repository.ts View File

@ -9,7 +9,6 @@ import type { FeatureAccess, Features, PlusFeatures } from '../../features';
import { Logger } from '../../logger';
import { showCreatePullRequestPrompt, showGenericErrorMessage } from '../../messages';
import { asRepoComparisonKey } from '../../repositories';
import type { StoredStarred } from '../../storage';
import { filterMap, groupByMap } from '../../system/array';
import { executeActionCommand, executeCoreGitCommand } from '../../system/command';
import { formatDate, fromNow } from '../../system/date';
@ -17,6 +16,7 @@ import { gate } from '../../system/decorators/gate';
import { debug, getLogScope, log, logName } from '../../system/decorators/log';
import { debounce } from '../../system/function';
import { filter, join, some } from '../../system/iterable';
import { updateRecordValue } from '../../system/object';
import { basename, normalizePath } from '../../system/path';
import { runGitCommandInTerminal } from '../../terminal';
import type { GitProviderDescriptor } from '../gitProvider';
@ -942,16 +942,7 @@ export class Repository implements Disposable {
private async updateStarredCore(key: 'branches' | 'repositories', id: string, star: boolean) {
const storageKey = `starred:${key}` as const;
let starred = this.container.storage.getWorkspace(storageKey);
if (starred === undefined) {
starred = Object.create(null) as StoredStarred;
}
if (star) {
starred[id] = true;
} else {
const { [id]: _, ...rest } = starred;
starred = rest;
}
starred = updateRecordValue(starred, id, star);
await this.container.storage.storeWorkspace(storageKey, starred);
this.fireChange(RepositoryChange.Starred);

+ 2
- 11
src/views/searchAndCompareView.ts View File

@ -16,6 +16,7 @@ import { filterMap } from '../system/array';
import { executeCommand } from '../system/command';
import { gate } from '../system/decorators/gate';
import { debug, log } from '../system/decorators/log';
import { updateRecordValue } from '../system/object';
import { isPromise } from '../system/promise';
import { ComparePickerNode } from './nodes/comparePickerNode';
import { CompareResultsNode } from './nodes/compareResultsNode';
@ -479,17 +480,7 @@ export class SearchAndCompareView extends ViewBase
async updatePinned(id: string, pin?: StoredPinnedItem) {
let pinned = this.container.storage.getWorkspace('views:searchAndCompare:pinned');
if (pinned == null) {
pinned = Object.create(null) as StoredPinnedItems;
}
if (pin != null) {
pinned[id] = { ...pin };
} else {
const { [id]: _, ...rest } = pinned;
pinned = rest;
}
pinned = updateRecordValue(pinned, id, pin);
await this.container.storage.storeWorkspace('views:searchAndCompare:pinned', pinned);
this.triggerNodeChange(this.ensureRoot());

Loading…
Cancel
Save