confirm chat delete & redirect, show msg form in single message view

This commit is contained in:
Martti Malmi 2022-06-23 22:52:21 +03:00
parent f68da66aef
commit 4c2d417834
6 changed files with 25 additions and 11 deletions

View File

@ -265,6 +265,7 @@ function getMyName() { return myName; }
function getMyProfilePhoto() { return myProfilePhoto; } function getMyProfilePhoto() { return myProfilePhoto; }
async function logOut() { async function logOut() {
route('/');
if (State.electron) { if (State.electron) {
State.electron.get('user').put(null); State.electron.get('user').put(null);
} }
@ -283,7 +284,6 @@ async function logOut() {
} }
clearIndexedDB(); clearIndexedDB();
localStorage.clear(); localStorage.clear();
route('/');
location.reload(); location.reload();
} }

View File

@ -284,8 +284,8 @@ async (serialized, a, b, event) => {
${(this.props.showReplies || s.showReplyForm) && s.sortedReplies && s.sortedReplies.length ? s.sortedReplies.map(r => ${(this.props.showReplies || s.showReplyForm) && s.sortedReplies && s.sortedReplies.length ? s.sortedReplies.map(r =>
html`<${PublicMessage} measure=${this.props.measure} key=${r.hash} hash=${r.hash} asReply=${true} showName=${true} showReplies=${true} />` html`<${PublicMessage} measure=${this.props.measure} key=${r.hash} hash=${r.hash} asReply=${true} showName=${true} showReplies=${true} />`
) : ''} ) : ''}
${s.showReplyForm ? html` ${this.props.standalone || s.showReplyForm ? html`
<${FeedMessageForm} replyingTo=${this.props.hash} replyingToUser=${s.msg.info.from} /> <${FeedMessageForm} autofocus=${!this.props.standalone} replyingTo=${this.props.hash} replyingToUser=${s.msg.info.from} />
` : ''} ` : ''}
</div> </div>
</div> </div>

View File

@ -1218,6 +1218,18 @@ class Channel {
gun.user().get('channels').get(channelId).put(null); gun.user().get('channels').get(channelId).put(null);
gun.user().get('channels').get(channelId).off(); gun.user().get('channels').get(channelId).off();
} }
/**
*
*/
static async deleteGroup(gun, key, uuid) {
const mySecret = await Gun.SEA.secret(key.epub, key);
const mySecretHash = await util.getHash(mySecret);
const mySecretUuid = await util.getHash(mySecretHash + uuid);
gun.user().auth(key);
gun.user().get('channels').get(mySecretUuid).put(null);
gun.user().get('channels').get(mySecretUuid).off();
}
} }
export default Channel; export default Channel;

View File

@ -15,11 +15,11 @@ import $ from 'jquery';
import QRCode from '../lib/qrcode.min'; import QRCode from '../lib/qrcode.min';
import iris from '../iris-lib'; import iris from '../iris-lib';
function deleteChat(pub) { function deleteChat(uuid) {
if (confirm("Delete chat?")) { if (confirm("Delete chat?")) {
iris.Channel.deleteChannel(State.public, Session.getKey(), pub); iris.Channel.deleteGroup(State.public, Session.getKey(), uuid);
delete Session.channels[pub]; delete Session.channels[uuid];
State.local.get('channels').get(pub).put(null); State.local.get('channels').get(uuid).put(null);
route('/chat'); route('/chat');
} }
} }

View File

@ -11,7 +11,6 @@ class Message extends View {
} }
renderView() { renderView() {
let content; let content;
if (this.props.hash === 'new') { if (this.props.hash === 'new') {
content = html` content = html`

View File

@ -22,9 +22,12 @@ import {Helmet} from "react-helmet";
import {SMS_VERIFIER_PUB} from '../SMS'; import {SMS_VERIFIER_PUB} from '../SMS';
function deleteChat(pub) { function deleteChat(pub) {
iris.Channel.deleteChannel(State.public, Session.getKey(), pub); if (confirm(`${t('delete_chat')}?`)) {
delete Session.channels[pub]; iris.Channel.deleteChannel(State.public, Session.getKey(), pub);
State.local.get('channels').get(pub).put(null); delete Session.channels[pub];
State.local.get('channels').get(pub).put(null);
route(`/chat`);
}
} }
class Profile extends View { class Profile extends View {