Skip to content

Conversation

@dibas
Copy link
Contributor

@dibas dibas commented Mar 16, 2018

It took me an embarrassingly long time to find this bug.

I have been trying to setup The Lounge as a WebShell app, but sessions were not saved at all. Well it turns out that while WebShell saves the data correctly, fetching our localStorage data with a key containing "Optional(key)" does not work, so force-unwrapping the key seems like the most feasible thing to do, which is exactly what this pull request does.

(There are still some weird problems with The Lounge, like not reading from localStorage at all sometimes, but at least session data is read correctly now. I might propose a few more pull requests if those problems are rooted in WebShell, not sure about it at the moment.)

@0xWDG 0xWDG self-requested a review March 16, 2018 19:38
@0xWDG 0xWDG assigned dibas and 0xWDG Mar 16, 2018
@0xWDG 0xWDG added this to the v0.2.5 milestone Mar 16, 2018
Copy link
Collaborator

@0xWDG 0xWDG left a comment

Choose a reason for hiding this comment

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

Please see my comment:
Is it maybe better to use

    if let LSvalue = key {
        let newKey = "WSLS:\(host):\(LSvalue)"
        // ... 
    }

otherwise, it will crash if no value is given, can you please test it and update your pull request?

Thanks in advance!

let getFromLocal: @convention(block)(NSString!) -> String = {(key: NSString!) in
let host: String = (self.mainWebview.mainFrame.dataSource?.request.url?.host)!
let newKey = "WSLS:\(host):\(key)"
let newKey = "WSLS:\(host):\(key!)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it maybe better to use

    if let LSvalue = key {
        let newKey = "WSLS:\(host):\(LSvalue)"
    }

otherwise, it will crash if no value is given, can you please test it and update your pull request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right of course. I'm pushing the changes.

@dibas
Copy link
Contributor Author

dibas commented Mar 16, 2018

Updated the code to prevent crashes.

@0xWDG
Copy link
Collaborator

0xWDG commented Mar 16, 2018

Thanks!

@0xWDG 0xWDG merged commit 4cbfa57 into djyde:master Mar 16, 2018
@dibas dibas deleted the patch-1 branch March 16, 2018 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants