You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-17 23:27:48 +02:00
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
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 {
|
|
static tableName() {
|
|
return 'master_keys';
|
|
}
|
|
|
|
static modelType() {
|
|
return BaseModel.TYPE_MASTER_KEY;
|
|
}
|
|
|
|
static encryptionSupported() {
|
|
return false;
|
|
}
|
|
|
|
static latest() {
|
|
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);
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|