Browse Source

Review fixes

Leszek Wiesner 4 years ago
parent
commit
e9fab7a03a

+ 1 - 1
cli/src/Api.ts

@@ -493,7 +493,7 @@ export default class Api {
   async availableClasses(useCache = true): Promise<[ClassId, Class][]> {
     return useCache && this._cdClassesCache
       ? this._cdClassesCache
-      : await this.entriesByIds<ClassId, Class>(this._api.query.contentDirectory.classById)
+      : (this._cdClassesCache = await this.entriesByIds<ClassId, Class>(this._api.query.contentDirectory.classById))
   }
 
   availableCuratorGroups(): Promise<[CuratorGroupId, CuratorGroup][]> {

+ 5 - 0
cli/src/base/AccountsCommandBase.ts

@@ -216,6 +216,11 @@ export default abstract class AccountsCommandBase extends ApiCommandBase {
   }
 
   async requestAccountDecoding(account: NamedKeyringPair): Promise<void> {
+    // Skip if account already unlocked
+    if (!account.isLocked) {
+      return
+    }
+
     // First - try decoding using empty string
     try {
       account.decodePkcs8('')

+ 2 - 4
cli/src/base/ContentDirectoryCommandBase.ts

@@ -245,10 +245,8 @@ export default abstract class ContentDirectoryCommandBase extends AccountsComman
     }, {} as Record<string, { value: Codec; type: string }>)
   }
 
-  async parseToKnownEntityJson<T>(entity: Entity, entityClass?: Class): Promise<FlattenRelations<T>> {
-    if (!entityClass) {
-      entityClass = (await this.classEntryByNameOrId(entity.class_id.toString()))[1]
-    }
+  async parseToKnownEntityJson<T>(entity: Entity): Promise<FlattenRelations<T>> {
+    const entityClass = (await this.classEntryByNameOrId(entity.class_id.toString()))[1]
     return (_.mapValues(this.parseEntityPropertyValues(entity, entityClass), (v) =>
       v.value.toJSON()
     ) as unknown) as FlattenRelations<T>