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

Possible bug: y-partykit readOnly option is not working properly #637

Open
AMR-21 opened this issue Dec 22, 2023 · 0 comments
Open

Possible bug: y-partykit readOnly option is not working properly #637

AMR-21 opened this issue Dec 22, 2023 · 0 comments

Comments

@AMR-21
Copy link

AMR-21 commented Dec 22, 2023

I was playing with the Tiptap example in the docs and I tried the readOnly option but it seemed not to be working. when I set it to true as shown down, I can still edit the editor and changes are propagated as if the option is set to false.

export default class implements Party.Server {
  constructor(public party: Party.Party) {}

  async onConnect(conn) {
    const party = this.party;
    const supabase = createClient(
      this.party.env.SUPABASE_URL as string,
      this.party.env.SUPABASE_KEY as string,
      { auth: { persistSession: false } }
    );
    await onConnect(conn, this.party, {
      // persist: false,

      readOnly: true,
      async load() {
        // const { data, error } = await supabase
        //   .from("documents")
        //   .select("document")
        //   .eq("name", party.id)
        //   .maybeSingle();
        // if (error) {
        //   console.error("ERROR", error);
        // }
        // if (data) {
        //   const doc = transformer.toYdoc(data.document, rootFragmentField);
        //   return doc;
        // } else {
        return new Y.Doc();
        // }
      },
      callback: {
        handler: async (doc) => {
          // console.log(doc);
          console.log("doc changed");
          // doc;
          const json = transformer.fromYdoc(doc, rootFragmentField);
          console.log(json);
        },
      },
    });
  }
}
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

No branches or pull requests

1 participant