Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving and retreiving a string value from client storage adds quotation marks #545

Closed
langfingaz opened this issue Nov 2, 2022 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@langfingaz
Copy link

Description

Saving and retreiving a string value from the client storage adds quotation marks around it.

Code example to reproduce the issue:

import flet
from flet import Page, TextField


class MyApp:
    @staticmethod
    def static_run(page: Page) -> None:
        MyApp(page)

    def __init__(self, page: Page):
        self.page: Page = page
        self.text_field = TextField(label="Value Store", value=self.get_text(), on_submit=self.save_text)
        self.page.add(self.text_field)
        self.text_field.focus()

    def get_text(self) -> str:
        key = "text"
        if self.page.client_storage.contains_key(key):
            return self.page.client_storage.get(key)
        else:
            return "Enter some text here."

    def save_text(self, e):
        key = "text"
        self.page.client_storage.set(key, self.text_field.value)


if __name__ == '__main__':
    flet.app(target=MyApp.static_run, assets_dir="assets")
    # flet.app(target=MyApp.static_run, assets_dir="assets", view=flet.WEB_BROWSER, port=8080)

Describe the results you received:

  1. Start the application
  2. Enter some text and press enter to save it to client storage

image
3. Stop and reopen the app. There are now quotations around the text

image

Flet version (pip show flet):

Version: 0.1.63

Operating system:

Arch Linux x86

Additional environment details:
I am using a venv with these requirements installed:

  • flet
  • py-staticmaps[cairo]
@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Nov 2, 2022

I tried adding a print to see the issue better.

image

And had this..

image

This is quite «bizard»/strange.

@FeodorFitsner
Copy link
Contributor

Can confirm - it's a bug. Thanks for reporting!

@FeodorFitsner
Copy link
Contributor

Fixed in the next release coming later this week.

For workaround unwrap the value with json.loads(), for example:

v = json.loads(page.client_storage.get("AAA"))

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Nov 2, 2022
@FeodorFitsner FeodorFitsner added this to the Controls-S3 milestone Nov 2, 2022
@FeodorFitsner FeodorFitsner added the status: working on it Working on a fix for the issue label Nov 2, 2022
FeodorFitsner added a commit that referenced this issue Nov 2, 2022
@langfingaz
Copy link
Author

Thanks for reporting!

You're welcome. Many thanks for your quick replies. Should I close this issue then or leave it open until the next release?

@FeodorFitsner
Copy link
Contributor

It will be closed automatically when PR is merged.

@FeodorFitsner FeodorFitsner removed the status: working on it Working on a fix for the issue label Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants