RocketChat / Apps.Github22

The ultimate AI-powered app extending Rocket.Chat for global developers collaborating on Github (2024 and beyond)
33 stars 39 forks source link

feat: migrate issues GET APIs to GithubSDK #145

Open JeffreytheCoder opened 7 months ago

JeffreytheCoder commented 7 months ago

Issue(s)

Fixes a part of #143

Acceptance Criteria fulfillment

Completed 6 migration tasks related to issues GET APIs

VipinDevelops commented 7 months ago

Hey @JeffreytheCoder great work with the migration I would suggest you attach a Video to show case that the Features are working as expected with new changes.

JeffreytheCoder commented 7 months ago

Thanks @VipinDevelops! I saw you created a GitHubApi instance for calling getBasicUserInfo in #144 .

https://github.com/RocketChat/Apps.Github22/blob/109aae39cdd45850b3ea12ac885b790251546c5c/github/modals/UserProfileModal.ts#L49-L57

But in this way, everytime we need to call an API, we need to create a instance and fetch properties like access_token and BaseHost.

I'm thinking of creating a GitHubApi singleton on app setup. On creation, the singleton will fetch and store the properties. All app actions can call APIs using the singleton. What do you think?

VipinDevelops commented 7 months ago

Hey @JeffreytheCoder Yesterday, @samad-yar-khan Also shared about this and suggested a new way to improve this with a nice reference,

Your approach is good, but let me first research the method Samad shared and then I can make a new PR that fixes this issue.

samad-yar-khan commented 6 months ago

@JeffreytheCoder @VipinDevelops I was thinking along the same lines as @JeffreytheCoder. We should think about two things while approaching the design for this class

JeffreytheCoder commented 6 months ago

@samad-yar-khan Thanks for the insights! Like my comment above, I think having token & URL stored in a singleton solves the issue of fetching themevery time. Whenever the user updates token & URL in the settings, we update the singleton too. What do you think?

VipinDevelops commented 6 months ago

I agree with @samad-yar-khan. @JeffreytheCoder, can you please implement it that way in this PR? Then, Samad can review it, and we can move forward from there and also update the few places where this new class is being used.

JeffreytheCoder commented 6 months ago

Implemented the singleton approach and applied to all migrated methods in this PR and in #144.

Behavior same as before: singleton

JeffreytheCoder commented 6 months ago

The singleton gets api host from environment and generates access token when initialized. We'll need to update these when user update settings / login / logout in another PR.