Skip to content

Commit

Permalink
Merge pull request #1 from vivek-nexus/v1.1.1
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
vivek-nexus authored Dec 30, 2023
2 parents f7b4b89 + f6432d5 commit 797be1b
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 21 deletions.
11 changes: 9 additions & 2 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
packagerConfig: {
asar: true,
icon: './images/icon'
},
rebuildConfig: {},
Expand All @@ -26,7 +27,13 @@ module.exports = {
options: {
icon: './images/icon.png'
}
},
}
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
]
],
};
66 changes: 59 additions & 7 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ const Store = require('electron-store');
const store = new Store()

// DOM
let slackTokenText = document.querySelector("#i-slack-token")
let saveButton = document.querySelector("#b-save")
let dndAddAnotherButton = document.querySelector("#b-dnd-set")
let statusAddAnotherButton = document.querySelector("#b-status-set")
let generateSlackTokenButton = document.querySelector("#generate-slack-token")
let appVersionText = document.querySelector("#app-version")
let downloadsButton = document.querySelector("#downloads")
const slackTokenText = document.querySelector("#i-slack-token")
const saveButton = document.querySelector("#b-save")
const dndAddAnotherButton = document.querySelector("#b-dnd-set")
const statusAddAnotherButton = document.querySelector("#b-status-set")
const generateSlackTokenButton = document.querySelector("#generate-slack-token")
const appVersionText = document.querySelector("#app-version")
const downloadsButton = document.querySelector("#downloads")


// slack token read / store messaging
ipcRenderer.invoke("read-slack-token").then((token) => {
if (token != "")
slackTokenText.value = "●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●"
})

ipcRenderer.on("auto-minimise", () => {
const abortFunction = startCountdown()
document.addEventListener("mousemove", abortFunction)
})


slackTokenText.addEventListener("keyup", function (event) {
if (slackTokenText.value != "●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●")
ipcRenderer.send("store-slack-token", slackTokenText.value)
Expand Down Expand Up @@ -346,4 +353,49 @@ function checkIfShortcutIsTaken(key, section, type, index) {
return taken
}

function startCountdown() {
const autoMinimseAlert = document.createElement("div")
autoMinimseAlert.id = "alert"
autoMinimseAlert.classList.add("alert", "alert-primary")
autoMinimseAlert.role = "alert"
// Set initial styles for the transition
autoMinimseAlert.style.opacity = "0";
autoMinimseAlert.style.transition = "opacity 0.5s ease-in-out";
document.querySelector("body").prepend(autoMinimseAlert);
// Trigger reflow to apply initial styles
autoMinimseAlert.offsetHeight;
// Set final styles to start the transition
autoMinimseAlert.style.opacity = "1";

let count = 3;
// Initial call to start the countdown
let timeoutId
updateCountdown()

function updateCountdown() {
autoMinimseAlert.textContent = `Minimising to system tray in ${count}`;

if (count === -1) {
autoMinimseAlert.textContent = "Auto minimising now"
autoMinimseAlert.remove()
ipcRenderer.send("minimise")
}
else {
// Continue the countdown
count--
// Schedule the next update after 1 second
timeoutId = setTimeout(updateCountdown, 1000)
}
}

// Function to abort the countdown
function abortCountdown() {
clearTimeout(timeoutId)
autoMinimseAlert.remove()
}

// Return the function to allow external abortion
return abortCountdown
}


16 changes: 10 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var autoLauncher = new AutoLaunch({
// Checking if autoLaunch is enabled, if not then enabling it.
autoLauncher.isEnabled().then(function (isEnabled) {
if (isEnabled) return;
autoLauncher.enable(); slackTokenInputField.value
autoLauncher.enable();
}).catch(function (err) {
throw err;
});
Expand All @@ -32,9 +32,6 @@ const contextMenu = Menu.buildFromTemplate([
app.dock.show()
}
mainWindow.show()
mainWindow.webContents.once("dom-ready", function () {
mainWindow.webContents.send("read-slack-token", readToken())
})
}
},
{
Expand All @@ -53,10 +50,18 @@ app.whenReady().then(() => {
loadDefaultValues()

mainWindow = createWindow()
mainWindow.webContents.once("dom-ready", function () {
if (readToken() != "")
mainWindow.webContents.send("auto-minimise")
})

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
mainWindow = createWindow()
mainWindow.webContents.once("dom-ready", function () {
if (readToken() != "")
mainWindow.webContents.send("auto-minimise")
})
}
})

Expand Down Expand Up @@ -399,13 +404,12 @@ function checkForUpdates() {
)
.then((response) => response.json())
.then((result) => {
if (result.version > app.getVersion()) {
if (result.version != app.getVersion()) {
new Notification({
title: `New update available!`,
body: `Click on downloads link in the app`
}).show();
}

})
.catch((err) => {
console.log(err);
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
"make": "electron-forge make"
},
"devDependencies": {
"@electron-forge/cli": "^6.1.1",
"@electron-forge/maker-deb": "^6.1.1",
"@electron-forge/maker-rpm": "^6.1.1",
"@electron-forge/maker-squirrel": "^6.1.1",
"@electron-forge/maker-zip": "^6.1.1",
"@electron-forge/cli": "^7.2.0",
"@electron-forge/maker-deb": "^7.2.0",
"@electron-forge/maker-rpm": "^7.2.0",
"@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
"electron": "^24.0.0"
},
"dependencies": {
"auto-launch": "^5.0.5",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^8.1.0"
}
}
}
5 changes: 5 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ body {
color: var(--font);
}

.alert {
text-align: center;
padding: 0.25rem;
}

p {
margin-bottom: 0;
color: var(--font);
Expand Down

0 comments on commit 797be1b

Please sign in to comment.