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

#292 Load UI lexicon #420

Merged
merged 2 commits into from
May 3, 2024
Merged

#292 Load UI lexicon #420

merged 2 commits into from
May 3, 2024

Conversation

Taufi
Copy link
Contributor

@Taufi Taufi commented May 3, 2024

Contributor checklist


Description

The UILexicon is unable to load due to the Language Database being located in the app's main bundle, where writing data is not permitted. The solution involves copying the database into the application support directory and accessing it from there.

Additionally, the pull request includes a minor fix for an issue in ParentTableCellModel.

The fix is tested on

  • iPhone 12, iOS 17.3.1. (physical device)
  • iPhone 15, iOS 17.0. (simulator)
  • iPad (10th generation), iOS 17.0 (simulator)
  • iPhone SE (3rd generation), iOS 17.0 (simulator)

The simulator tests are essentially retests because the error doesn't manifest there.

Related issue

Copy link

github-actions bot commented May 3, 2024

Thank you for the pull request!

The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and iOS rooms once you're in. It'd be great to have you!

Maintainer checklist

  • The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution

    • The contributor's name and icon in remote commits should be the same as what appears in the PR
    • If there's a mismatch, the contributor needs to make sure that the email they use for GitHub matches what they have for git config user.email in their local Scribe-iOS repo
  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@andrewtavis andrewtavis self-requested a review May 3, 2024 16:17
@andrewtavis
Copy link
Member

Thanks for this, @Taufi! Really happy to be able to add this feature in :) I'll get to the review today or tomorrow 😊

@Taufi
Copy link
Contributor Author

Taufi commented May 3, 2024

An explanation of the solution: I copy the database to the application support directory, and this operation occurs within the openDBQueue method. This method is utilized to initialize the lazy property languageDB. However, this approach introduces another issue. According to Apple's documentation, a lazy variable isn't inherently thread-safe: "If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property hasn't yet been initialized, there's no guarantee that the property will be initialized only once." This precisely mirrors the situation here, as the method is executed multiple times, causing unexpected behavior during the database copying process. To address this, I've redefined the languageDB property as a standard (optional) variable and initialized it within the init() method.

hasToggle: Bool = false, h _: Bool = false,

hasToggle: Bool = false,
hasNestedNavigation: Bool = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly very confused how this even got through 🤔 Maybe just something from auto save when I was using VS Code to format? Thanks again! :)

Copy link
Member

@andrewtavis andrewtavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is working beautifully, @Taufi 😊 Thanks so much for the getting to this and also for the explanation of the steps. Made everything much easier to understand 🎉

Hope you have a wonderful weekend! Looking forward to the next issue you pick up :)

@andrewtavis andrewtavis merged commit 6c41b8e into scribe-org:main May 3, 2024
2 checks passed
@Taufi Taufi deleted the ui-lexicon branch May 4, 2024 10:05
@mostazomarc mostazomarc mentioned this pull request May 5, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants