Prettified Code!

This commit is contained in:
DJ2LS 2023-02-25 22:24:28 +00:00 committed by GitHub Action
parent dc0fc959ad
commit 5bd3d3ef64
2 changed files with 16 additions and 27 deletions

View file

@ -3,7 +3,6 @@ const { ipcRenderer } = require("electron");
const { v4: uuidv4 } = require("uuid"); const { v4: uuidv4 } = require("uuid");
const imageCompression = require("browser-image-compression"); const imageCompression = require("browser-image-compression");
// https://stackoverflow.com/a/26227660 // https://stackoverflow.com/a/26227660
var appDataFolder = var appDataFolder =
process.env.APPDATA || process.env.APPDATA ||
@ -73,10 +72,8 @@ var users = new PouchDB(userDB);
createChatIndex(); createChatIndex();
createUserIndex(); createUserIndex();
// REMOTE SYNC ATTEMPTS // REMOTE SYNC ATTEMPTS
//var remoteDB = new PouchDB('http://172.20.10.4:5984/chatDB') //var remoteDB = new PouchDB('http://172.20.10.4:5984/chatDB')
/* /*
// we need express packages for running pouchdb sync "express-pouchdb" // we need express packages for running pouchdb sync "express-pouchdb"
@ -377,15 +374,12 @@ window.addEventListener("DOMContentLoaded", () => {
update_chat_obj_by_uuid(uuid); update_chat_obj_by_uuid(uuid);
}); });
// open file selector for user image // open file selector for user image
document.getElementById("userImageSelector").addEventListener("click", () => { document.getElementById("userImageSelector").addEventListener("click", () => {
ipcRenderer.send("select-user-image", {
ipcRenderer.send("select-user-image", {
title: "Title", title: "Title",
}); });
});
});
// SEND MSG // SEND MSG
document.getElementById("sendMessage").addEventListener("click", () => { document.getElementById("sendMessage").addEventListener("click", () => {
@ -510,38 +504,33 @@ ipcRenderer.on("return-select-user-image", (event, arg) => {
//document.getElementById("userImage").src = ''; //document.getElementById("userImage").src = '';
//var imageFile = arg.data; //var imageFile = arg.data;
var imageFile = arg.data; var imageFile = arg.data;
console.log(imageFile) console.log(imageFile);
var options = { var options = {
maxSizeMB: 1, maxSizeMB: 1,
maxWidthOrHeight: 1920, maxWidthOrHeight: 1920,
useWebWorker: true useWebWorker: true,
} };
imageCompression(imageFile, options) imageCompression(imageFile, options)
.then(function (compressedFile) { .then(function (compressedFile) {
console.log('compressedFile instanceof Blob', compressedFile instanceof Blob); // true console.log(
console.log(`compressedFile size ${compressedFile.size / 1024 / 1024} MB`); // smaller than maxSizeMB "compressedFile instanceof Blob",
compressedFile instanceof Blob
); // true
console.log(
`compressedFile size ${compressedFile.size / 1024 / 1024} MB`
); // smaller than maxSizeMB
console.log(compressedFile.size); console.log(compressedFile.size);
}) })
.catch(function (error) { .catch(function (error) {
console.log(error.message); console.log(error.message);
}); });
}); });
ipcRenderer.on("action-update-transmission-status", (event, arg) => { ipcRenderer.on("action-update-transmission-status", (event, arg) => {
var data = arg["data"][0]; var data = arg["data"][0];
console.log(data.status); console.log(data.status);

View file

@ -35,7 +35,7 @@
type="module" type="module"
src="../node_modules/emoji-picker-element/database.js" src="../node_modules/emoji-picker-element/database.js"
></script> ></script>
<script <script
type="module" type="module"
src="../node_modules/browser-image-compression/dist/browser-image-compression.js" src="../node_modules/browser-image-compression/dist/browser-image-compression.js"
></script> ></script>