Add clicking the status icon to toggle encryption
This commit is contained in:
parent
9880152290
commit
dac3187866
|
@ -22,6 +22,7 @@ export default new class E2EE extends BuiltinModule {
|
|||
constructor() {
|
||||
super();
|
||||
this.master = this.encrypt(seed, 'temporarymasterkey');
|
||||
this.encryptNewMessages = true;
|
||||
}
|
||||
|
||||
setMaster(key) {
|
||||
|
@ -36,7 +37,7 @@ export default new class E2EE extends BuiltinModule {
|
|||
}
|
||||
|
||||
get database() {
|
||||
return Settings.getSet('security').settings.find(s => s.id === 'e2eedb').settings[0].value;
|
||||
return Settings.getSetting('security', 'e2eedb', 'e2ekvps').value;
|
||||
}
|
||||
|
||||
encrypt(key, content, prefix = '') {
|
||||
|
@ -109,7 +110,7 @@ export default new class E2EE extends BuiltinModule {
|
|||
|
||||
handleChannelTextAreaSubmit(component, args, retVal) {
|
||||
const key = this.getKey(DiscordApi.currentChannel.id);
|
||||
if (!key) return;
|
||||
if (!this.encryptNewMessages || !key) return;
|
||||
component.props.value = this.encrypt(this.decrypt(this.decrypt(seed, this.master), key), component.props.value, '$:');
|
||||
}
|
||||
|
||||
|
|
|
@ -10,21 +10,19 @@
|
|||
|
||||
<template>
|
||||
<div class="bd-e2eeTaContainer">
|
||||
<template v-if="error">
|
||||
<div class="bd-e2eeTaBtn bd-e2eeLock bd-error">
|
||||
<MiLock v-tooltip="error" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="state === 'loading'">
|
||||
<div class="bd-e2eeTaBtn bd-e2eeLock bd-warn">
|
||||
<MiLock v-tooltip="'Loading'" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="bd-e2eeTaBtn bd-e2eeLock bd-ok">
|
||||
<MiLock v-tooltip="'Ready!'" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="error" class="bd-e2eeTaBtn bd-e2eeLock bd-error">
|
||||
<MiLock v-tooltip="error" />
|
||||
</div>
|
||||
<div v-else-if="state === 'loading'" class="bd-e2eeTaBtn bd-e2eeLock bd-loading bd-warn">
|
||||
<MiLock v-tooltip="'Loading'" />
|
||||
</div>
|
||||
<div v-else-if="!E2EE.encryptNewMessages" class="bd-e2eeTaBtn bd-e2eeLock bd-warn" @click="E2EE.encryptNewMessages = true">
|
||||
<MiLock v-tooltip="'New messages will not be encrypted.'" />
|
||||
</div>
|
||||
<div v-else class="bd-e2eeTaBtn bd-e2eeLock bd-ok" @click="E2EE.encryptNewMessages = false">
|
||||
<MiLock v-tooltip="'Ready!'" />
|
||||
</div>
|
||||
|
||||
<div class="bd-taDivider"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -33,10 +31,12 @@
|
|||
import { E2EE } from 'builtin';
|
||||
import { DiscordApi } from 'modules';
|
||||
import { MiLock } from '../ui/components/common/MaterialIcon';
|
||||
|
||||
export default {
|
||||
components: { MiLock },
|
||||
data() {
|
||||
return {
|
||||
E2EE,
|
||||
state: 'loading',
|
||||
error: null
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue