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

refactor: indexable base #99

Merged
merged 17 commits into from
May 27, 2022
Merged

Conversation

not-so-smart
Copy link
Member

This is a massive overhaul with a number of huge refactoring changes:

  • adds a Base class with _clone() and _patch() methods which all other structures extend
  • makes Managers generic on Base rather than Indexable
  • also makes Managers generic on the constructor of the class they are managing
  • minor changes to Users and Members
  • various changes to Polls (very much WIP still)

and delete UserData type, using APIUser instead
because `avatar` was a property of UserData and `avatar_url` is a property of APIUser

BREAKING CHANGE: User constructor no longer accepts `avatar` property; use `avatar_url` instead
first argument is now `client` to match other subclasses of `Base`

BREAKING CHANGE: Channel constructor changed:
`Channel(ChannelData)` -> `Channel(Client, ChannelData)`
todo: fix the unsafe type assertion
todo: fix the unsafe type assertion
because this is different from User#avatar_url and I didn't know that at the time
(and extend `Base`)
this makes managers generic on their held data types AND the held data type's constructor. Also replaces the Indexable interface with the Base class, so BaseManager is now generic on Base instead of Indexable
@@ -27,7 +30,7 @@ export default class FormerGroupManager extends BaseManager<FormerGroup> impleme
const user = this.client.users._upsert(
new User(this.client, {
id: data.user_id,
avatar: data.image_url,
avatar_url: data.image_url,
Copy link
Contributor

Choose a reason for hiding this comment

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

data.image_url is of type string | null, while avatar_url is of type string. This type error occurs in several places: FormerGroupManager.ts, GroupManager.ts, Message.ts, and Relationship.ts.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh right, that's because I updated some stuff in the types repo and forgot to push those changes sorry

missed this one somehow the first time around
including groupme-api-types@2.0.0
@not-so-smart not-so-smart merged commit 80ed00d into groupme-js:main May 27, 2022
@not-so-smart not-so-smart deleted the indexable-base branch May 27, 2022 18:02
@ngm-bot
Copy link
Member

ngm-bot commented May 27, 2022

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants