b0bdN / prayer-times-menubar-app

A menubar application for displaying the prayer times from your city.
MIT License
15 stars 20 forks source link

check if there is a comma in the input City, Country #5

Closed b0bdN closed 2 years ago

b0bdN commented 2 years ago

https://github.com/b0bdN/prayer-times-menubar-app/blob/15074588857dacaefe949cbc30705014df91b53c/main.js#L234

We need to check if there is a comma (,) in the input for the City, Country when the user enter manually the information.

I think of two options:

  1. the comma is mandatory, so we need to create a dialog box to show the error.
  2. it's ok to have just a space between CITY and COUNTRY
longtongj28 commented 2 years ago

Hello, can you assign this to me?

b0bdN commented 2 years ago

Hi!, thanks for your interest! Of course you can work on this :)

What do you think will be best, should the comma be mandatory?

longtongj28 commented 2 years ago

Some cities can be multiple words right? We should keep the comma mandatory

longtongj28 commented 2 years ago

I am new to electron. Could you show me where in your code to create a dialog box in your to show the error? I have the logic that handles if the input is valid.

b0bdN commented 2 years ago

No worries ;) I think it will be better to check the input in the renderer process when the user click on the Apply button before sending all the values to the Main process. https://github.com/b0bdN/prayer-times-menubar-app/blob/06db1671277492d48a40d719682de747b8de5d77/renderer.js#L228

dialog work only in the Main process, so you need to create an Inter-process communication (IPC) between the Renderer and the Main. You can use window.api.send('custom-channel', arg), add custom-channel in preload.js and listen in main.js with ipcMain.on('custom-channel', () => {dialog...}