aayushai / TranspilerX

Code converter from one programming language to another.
https://transpiler-x.vercel.app
MIT License
4 stars 12 forks source link

Preserve State Between Sessions with LocalStorage #23

Open aayushai opened 1 month ago

aayushai commented 1 month ago

Preserve State Between Sessions with LocalStorage

Description:

Allow users to preserve their selected languages and input/output code between sessions by saving the state in localStorage.

Action Items:

Example Code:

useEffect(() => {
  const savedInputLang = localStorage.getItem('inputLang');
  if (savedInputLang) setInputLang(savedInputLang);
}, []);

useEffect(() => {
  localStorage.setItem('inputLang', inputLang);
}, [inputLang]);

Reference:

thevashuydv commented 1 month ago

@aayushai assign to me please

aayushai commented 1 month ago

I'll assign it, first work on the previous assigned issue.

gurshaan17 commented 1 month ago

@aayushai can you assign it to me?

Arihant-Singh-Rana commented 1 month ago

Hello! And Greeting of the day Mr.@aayushai ! I was wondering if you could assign this task to me ?

aayushai commented 1 month ago

Go ahead @Arihant-Singh-Rana

thevashuydv commented 1 month ago

hey @aayushai i am facing an issue in resolving this issue can you please assign me some other issue.

aayushai commented 1 month ago

@thevashuydv don't worry I'll do it

Arihant-Singh-Rana commented 1 month ago

Hi! @aayushai, Greetings of the day! I have submitted the PR for this issue. Please review it and let me know if any changes are required!

aayushai commented 1 month ago

Hi @Arihant-Singh-Rana , I reviewed the code, and while the language selection state is being saved correctly, I noticed that the input and output code states are not being preserved. To clarify, I expect both the input code and the output code, along with the language selections, to be saved as well. Please make the necessary adjustments to ensure all three states (input code, output code, and language selection) are persisted.

Arihant-Singh-Rana commented 1 month ago

Oh ! Ok I'll make the necessary changes right away!

Arihant-Singh-Rana commented 4 weeks ago

Hi! @aayushai, I have made the necessary changes butI also wanted to know that once when we have converted the code it will save the state of the language selection as well as input and out code, but when we change the input Lang selection do you want the default code of the Lang that we just selected to appear in the editor or not ? similarly if we change the output Lang selection do you want the editor to refresh(as in remove the previously converted code and empty the editor) or not ?

aayushai commented 4 weeks ago

For now, let's keep it only for language selection, I have something in mind that will be implemented next for this website.

Arihant-Singh-Rana commented 4 weeks ago

@aayushai so should I not save the input code and output code ?

aayushai commented 4 weeks ago

No leave it, only save the language selector for now. Make a new PR with latest rebased fork. I'll merge it.

Arihant-Singh-Rana commented 4 weeks ago

@aayushai By the I have already made it so the input and output code is also saved and when we change the input code the default code will replace the saved code ..... So should I just make a new PR with that code or not?

Arihant-Singh-Rana commented 3 weeks ago

@aayushai By the I have already made it so the input and output code is also saved and when we change the input code the default code will replace the saved code ..... So should I just make a new PR with that code or not?

@aayushai which one should I submit the PR of? I have both the fix one where only the lang state is saved and other where both lang and code state is saved as well

aayushai commented 3 weeks ago

Hi @Arihant-Singh-Rana , make PR of only language state save.

Arihant-Singh-Rana commented 3 weeks ago

Hi @Arihant-Singh-Rana , make PR of only language state save.

Ok! I have already made the PR