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

Revise how contacts() works #602

Closed
j4hangir opened this issue Jan 14, 2021 · 7 comments
Closed

Revise how contacts() works #602

j4hangir opened this issue Jan 14, 2021 · 7 comments

Comments

@j4hangir
Copy link

j4hangir commented Jan 14, 2021

At the moment it is not possible to retrieve a list of all contacts directly, one has to make a call to .contacts() and provide a CB to retrieve them one by one:

contacts: {
    value: function(callback, context) {
      const cb = (callback || this.onMetaSub);
      if (cb) {
        for (let idx in this._contacts) {
          cb.call(context, this._contacts[idx], idx, this._contacts);
        }
      }
    },
    enumerable: true,
    configurable: true,
    writable: true
  }

Getting the list of all contacts at once is sometimes very handy and accessing the private property doesn't sound like a good idea.

I suggest either a getContacts() is set for the _contacts, possibly with a promise, or another way is devised for retrieving the list.

@or-else
Copy link
Contributor

or-else commented Jan 14, 2021

I did it this way because I wanted it to be read-only. It was too difficult to make this property read-only using JS so I resorted to using the iterator. I don't mind exposing the value but please don't call it getXXX because getXXX here is used to fetch data from the server, i.e. implies a network call. And if you can, then make it read-only.

@or-else
Copy link
Contributor

or-else commented Jan 14, 2021

Please send a pull request.

@or-else
Copy link
Contributor

or-else commented Jan 14, 2021

Against next.

@or-else
Copy link
Contributor

or-else commented Jan 14, 2021

@SatoshiNakamotogmx Are you asking about what a pull request is?
https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-pull-requests

It's only needed if you would like to make changes to the code which you want to be incorporated in the upstream.

@j4hangir
Copy link
Author

j4hangir commented Jan 16, 2021

Please send a pull request.

Think this will do: tinode/tinode-js#43

@j4hangir
Copy link
Author

Either way I don't care anymore, I'll work around it.

This process has been too tedious and bureaucratic.

@or-else
Copy link
Contributor

or-else commented Jan 18, 2021

Thanks

@or-else or-else closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants