-
Notifications
You must be signed in to change notification settings - Fork 385
Subscribe/Unsubscribe #2482
base: master
Are you sure you want to change the base?
Subscribe/Unsubscribe #2482
Conversation
Not super familiar with the subscriptions side of it all but I believe in this context a thread is just an issue and/or Pull Request so you're looking for the ID of the Issue/PR
I'm thinking this because if you look at the protocol |
@@ -12,6 +12,10 @@ import StyledTextKit | |||
|
|||
extension IssueOrPullRequestQuery.Data.Repository.IssueOrPullRequest.AsPullRequest: IssueType { | |||
|
|||
var viewerSubscribed: Bool { | |||
return viewerSubscription?.rawValue != "IGNORED" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We should use a constant for this value here: SubscriptionState.ignored.rawValue
Classes/Issues/Issue+IssueType.swift
Outdated
@@ -11,6 +11,10 @@ import IGListKit | |||
|
|||
extension IssueOrPullRequestQuery.Data.Repository.IssueOrPullRequest.AsIssue: IssueType { | |||
|
|||
var viewerSubscribed: Bool { | |||
return viewerSubscription?.rawValue != "IGNORED" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We should use a constant for this value here: SubscriptionState.ignored.rawValue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shall fix this!
@Sherlouk I tried that. I put a print statement to get that ID and I put a print to get the ID of the issue in the inbox and the ids were different. One was: 182635 (or something like that, all numbers) and then the other was the MDEx.... iD 🤔. Thoughts? Sent with GitHawk |
If it's all numbers it sounds like it could just be the PR/Issue number (e.g. this one is #2482) I believe it should just be the There don't appear to be any other IDs 🤔 Unless this is one of those stupid APIs where v4 API doesn't surface information you need in the V3 API. We've done some mad hacks in the past for that |
In the docs you can see it’s called a thread_id rather than a regular ID, not really sure where to get that/what that is. In the NotificationModelController it’s called v3id, so seems to be some V3 API. If you capture the v3id you get something like: 415678928 (this is an actual example for this thread) Sent with GitHawk |
Well, this is frustrating. I ended up posting on the Github Dev Forum. So close to finishing this :/ |
@Sherlouk Oh that looks like it could work. Any idea what the mutation would look like. I'm barely familiar with V3, so if you have an idea that could get me started that would be great. |
@Huddie It's been a while so I don't know how much I can help specifically but if you look at the add comment flow or the add/remove reaction flow then both of these use V4 mutations to work! Should be able to reuse/take notes from those implementations! If you have any specific questions though feel free to post them and I'm sure someone here will be able to help if not myself! |
@Sherlouk great idea with V4 mutation. The mutation I added (UpdateSubscription.graphql) works in graphiQL
but doesn't seem to work in-app. I'm not getting back an error, just nil and nothing is changing on github. When I used GraphiQL I am able to change the subscription status on github. Any ideas? |
Hmm 😬 Interesting that it works in one but not the other - one would think it has something to do with the inputs at that point? Maybe @rnystrom can help here, has a lot more knowledge! |
@Sherlouk Got it working, dumb mistake on my part. Thanks for the help.
why would subscribing to threads require any special access? If anything I feel like sub/unsub should be open to all repos regardless of access. Plus I can sub/unsub on github.com so it must be a mistake i'm making. Any ideas? |
@ijm8710 The only necessary permission im pretty sure is 'notifications' |
Yeah exactly, I would be shocked if you run into that issue with the pat |
@rnystrom PAT works. I removed all scopes but those we ask for in GitHawk and it worked. I don't think this is a scope issue. Seems to be a PAT vs OAuth difference. |
Yeah this all goes back to what ryan and I summed up in #2376 per what we investigated in #2165. Imo, unless GitHub changes how the OAuth works (because I think all of us agree the OAuth alone should grant sufficient access) the permissions should be reset for all current githawk users and reapplied going forward for all new githawk users to grant permissions on a token and not OAuth level or make it apply both Either way since the PAT issue affects in other places as well I don’t see it as a holdup in this ticket though |
I don’t know if it’s a blocker for this, the same error message occurs for other actions, like reactions, right? Sent with GitHawk |
Def don’t put on shelf! It’s the same error message you get for even more critical items such as posting comments in some repos as well. (PAT issues have existed for a while) The awesome work on this is not really being newly blocked by anything. If anything that just increases priority on fixing PAT but again no new issue here. |
@ijm8710 Thanks! Well... in that case @rnystrom this is ready for review 😀 General changes:
|
Just quick food for thought- where the ‘edit title addition’ would order-up relating to your second bullet (believe that PR was close to completed). Honestly I think the staticness of the button, now, raises even more support for the discussed addition of the mark read button intra-post being through the burger as welll. I think there could be a bunch of viable options perhaps for the burger menu now that it’s always visible👍 please don’t take this as a hijack just hitting on bullet 2 :) |
@ijm8710 Not sure I fully follow but does this have to do with this PR specifically or is it something that should be addressed later? Just want to make sure this thread isn’t about future idea/features and is strictly about this PR. I’m sure it’s related to this topic but if it isn’t about changing a piece of code in this PR or reason it shouldn’t be merged I think it’s better fit for an issue Sent with GitHawk |
Just talking the burger menu button order in general as some things were already in the works coming to it and you brought it up. It can be revisited further in those tickets but since you mentioned the order of it and also how it’s always static I thought it should be on mind Awesome work again! |
Haven't had time to catch up. @Huddie what's the current status w/ this? |
@rnystrom Sorry for the delay. So I tested this after pulling upstream and still works. It still has the PAT issue but that won't be fixed until all PAT issues are fixed. Once/If this is merged the manager button will always be present because you can always sub/unsub from a thread that you have access to. So I guess this is waiting for your review ATM |
@BasThomas Can I get a review on this. Might have time next week to fix it up if there are requested changes. Sent with GitHawk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested this, but it's looking good :)
func setSubscription( | ||
previous: IssueResult, | ||
subscribe: Bool, | ||
completion: ((Result<SubscriptionState?>) -> Void)? = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, what would it mean if the state
is nil
? Would that be an actual success?
let cache = self.cache | ||
cache.set(value: optimisticResult) | ||
|
||
let mutation = UpdateSubscriptionMutation(subscribable_Id: previous.id, subscription_state: state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change these parameters to camelCase
?
iconName = "unmute" | ||
case .unsubscribe: | ||
title = Constants.Strings.unsubscribe | ||
iconName = "mute" | ||
} | ||
|
||
// Lock always has the divider above it assuming you're a collaborator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update this comment.
@@ -114,9 +114,7 @@ class SplitViewTests: XCTestCase { | |||
client: GithubClient(userSession: nil), | |||
repo: RepositoryDetails( | |||
owner: "Foo", | |||
name: "Bar", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait... do we not have this already? You can unsubscribe from the issue overview, isn't it? Am I missing something?
@BasThomas can you explain where you think we have this again? Not sure I fully understood Sent with GitHawk |
Sent with GitHawk |
@BasThomas ya so that’s true for notifications. If you comment on a issue etc etc you get subscribed and then once you get the notification you can unsubscribe. Here you can pick any issue and subscribe to it, and the. Unsubscribe whenever as wel, even if you hasn’t gotten a notification. Sent with GitHawk |
Closes #2149
So I think I have everything in place. Just need to configure the request that subscribes and unsubscribes.
Where I'm a bit stuck:
There is a difference between watching repositories (https://developer.github.com/v3/activity/watching/) vs subscribing a thread https://developer.github.com/v3/activity/notifications/).
I think we're looking for the latter and so I'm trying to figure out how to obtain the thread_id from the issueOrPullRequest query that we use. We have
V3SubscribeThreadRequest
which takes anid
andignore
. So once I get the thread_id I can pass it in.Anyone know where I can get the thread_id from the issueOrPullRequest query response?
@Sherlouk you seem to know the GitHub API stuff well!