firepad icon indicating copy to clipboard operation
firepad copied to clipboard

Using Date.now() as userId triggers Invalid operation exception and no syncing.

Open freskoulix opened this issue 9 years ago • 2 comments

Greetings, I am having difficulty to start with firepad, I wrote a simple page which is as follows:

<html>
<head>
<title>Demo</title>

<link rel="stylesheet" href="//cdn.firebase.com/libs/firepad/1.3.0/firepad.css" />
<style>
    #editor {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }
</style>
</head>
<body>
<div id="editor"></div>

<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
<script src="//cdn.firebase.com/js/client/2.4.0/firebase.js"></script>
<script src="//cdn.firebase.com/libs/firepad/1.3.0/firepad.min.js"></script>

<script>
$(function () {
    var editor = ace.edit("editor");
    editor.getSession().setMode("ace/mode/javascript");

    var firepadRef = new Firebase('FIREBASE_IDENTIFIER.firebaseIO.com' + '/demo');
    Firepad.fromACE(firepadRef, editor, {
        userId: Date.now()
    });
});
</script>
</body>
</html>

When I enter the first character I get an Invalid operation error in console firepad

The firebase DB seems to update thou: db

Any other open client doesn't sync with the operation.

Can anybody help?

freskoulix avatar Feb 13 '16 10:02 freskoulix

So it looks like the issue is having a number as the userId instead of a string. If you change your code to userId: "" + Date.now() then I think it'll work. I'm not sure why this causes an issue though. I'm going to change the title of your issue and leave it around until I have time to investigate.

mikelehen avatar Feb 15 '16 19:02 mikelehen

Yes, passing a string into userId works. Thanks a lot!

freskoulix avatar Feb 16 '16 16:02 freskoulix