This repository was archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 387
Subscribe/Unsubscribe #2482
Open
Huddie
wants to merge
7
commits into
GitHawkApp:master
Choose a base branch
from
Huddie:sub-unsub
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Subscribe/Unsubscribe #2482
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ab5e531
Subscribe/Unsubscribe
Huddie aa61bca
Working on mutation
Huddie bbda2d3
Fixed mutation
Huddie 5f1f379
Fixed code logic
Huddie 35758ba
Fixing merge
Huddie 9124e6d
Fixed test
Huddie 7cbe77a
Switched ignored to unsubscribed
Huddie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,8 @@ final class IssueManagingContextController: NSObject, ContextMenuDelegate { | |
case lock | ||
case reopen | ||
case close | ||
case subscribe | ||
case unsubscribe | ||
} | ||
|
||
var actions: [Action] { | ||
|
@@ -97,6 +99,15 @@ final class IssueManagingContextController: NSObject, ContextMenuDelegate { | |
if result.pullRequest { | ||
actions.append(.reviewers) | ||
} | ||
} | ||
|
||
if result.viewerIsSubscribed { | ||
actions.append(.unsubscribe) | ||
} else { | ||
actions.append(.subscribe) | ||
} | ||
|
||
if case .collaborator = permissions { | ||
if result.labels.locked { | ||
actions.append(.unlock) | ||
} else { | ||
|
@@ -144,13 +155,19 @@ final class IssueManagingContextController: NSObject, ContextMenuDelegate { | |
case .close: | ||
title = Constants.Strings.close | ||
iconName = "x" | ||
case .subscribe: | ||
title = Constants.Strings.subscribe | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. We should update this comment. |
||
// If you aren't a collaborator (Lock does not show), close has the divider above it. | ||
let separator: Bool | ||
switch action { | ||
case .lock, .unlock: separator = true | ||
case .subscribe, .unsubscribe: separator = true | ||
case .reopen, .close: separator = permissions != .collaborator | ||
default: separator = false | ||
} | ||
|
@@ -186,6 +203,8 @@ final class IssueManagingContextController: NSObject, ContextMenuDelegate { | |
case .lock: strongSelf.lock(true) | ||
case .reopen: strongSelf.close(false) | ||
case .close: strongSelf.close(true) | ||
case .subscribe: strongSelf.subscribe(true) | ||
case .unsubscribe: strongSelf.subscribe(false) | ||
} | ||
} | ||
} | ||
|
@@ -271,6 +290,12 @@ final class IssueManagingContextController: NSObject, ContextMenuDelegate { | |
) | ||
} | ||
|
||
func subscribe(_ doSubscribe: Bool) { | ||
guard let previous = result else { return } | ||
delegate?.willMutateModel(from: self) | ||
client.setSubscription(previous: previous, subscribed: doSubscribe) | ||
Haptic.triggerNotification(.success) | ||
} | ||
func close(_ doClose: Bool) { | ||
guard let previous = result else { return } | ||
delegate?.willMutateModel(from: self) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. nit: We should use a constant for this value here: |
||
} | ||
|
||
var pullRequest: Bool { | ||
return true | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!