1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-20 23:30:05 +02:00
This commit is contained in:
Laurent Cozic
2021-06-26 18:18:10 +01:00
parent 400ede122d
commit 05e4b32d9b
41 changed files with 284 additions and 109 deletions

View File

@@ -1,5 +1,6 @@
import BaseModel from '../BaseModel';
import { MasterKeyEntity } from '../services/database/types';
import { masterKeyAll, masterKeyById, saveMasterKey } from '../services/synchronizer/syncTargetInfoUtils';
import BaseItem from './BaseItem';
export default class MasterKey extends BaseItem {
@@ -16,20 +17,30 @@ export default class MasterKey extends BaseItem {
}
static latest() {
return this.modelSelectOne('SELECT * FROM master_keys WHERE created_time >= (SELECT max(created_time) FROM master_keys)');
throw new Error('Not implemented');
// return this.modelSelectOne('SELECT * FROM master_keys WHERE created_time >= (SELECT max(created_time) FROM master_keys)');
}
static allWithoutEncryptionMethod(masterKeys: MasterKeyEntity[], method: number) {
return masterKeys.filter(m => m.encryption_method !== method);
}
static async save(o: MasterKeyEntity, options: any = null) {
return super.save(o, options).then(item => {
this.dispatch({
type: 'MASTERKEY_UPDATE_ONE',
item: item,
});
return item;
public static async load(id: string): Promise<MasterKeyEntity> {
return masterKeyById(id);
}
public static async all(): Promise<MasterKeyEntity[]> {
return masterKeyAll();
}
public static async save(o: MasterKeyEntity): Promise<MasterKeyEntity> {
const newMasterKey = saveMasterKey(o);
this.dispatch({
type: 'MASTERKEY_UPDATE_ONE',
item: newMasterKey,
});
return newMasterKey;
}
}