forked from hackforla/website
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor "Schedule Friday" for modularity (hackforla#7367)
* refactor, reuse, and consolidate * fix issueNum in query-issue-info.js * add HackforLABot login, refs to api, del https ref * tweaks to comments * Update hide-issue-comment.js edited `nodeID` --> `nodeId` both to fix an error in mismatched cases and also to make consistent with other `Id`s.
- Loading branch information
1 parent
bfa9f15
commit 1fd10e6
Showing
4 changed files
with
48 additions
and
99 deletions.
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 |
---|---|---|
@@ -1,26 +1,29 @@ | ||
/** | ||
* Hide a comment as OUTDATED on github | ||
* @param {Number} nodeID - the comment to be marked as 'OUTDATED' | ||
* Minimize issue comment as OUTDATED given the comment's node Id | ||
* @param {String} nodeId - node Id of comment to be marked as 'OUTDATED' | ||
* | ||
*/ | ||
async function minimizeIssueComment(github, nodeId) { | ||
|
||
async function hideComment(github, nodeID) { | ||
const reason = "OUTDATED" | ||
try { | ||
const resp = await github.graphql(` | ||
mutation { | ||
minimizeComment(input: {classifier: ${reason}, subjectId: "${nodeID}"}) { | ||
minimizedComment { | ||
isMinimized | ||
} | ||
} | ||
const mutation = `mutation($nodeId: ID!) { | ||
minimizeComment(input: {classifier: OUTDATED, subjectId: $nodeId}) { | ||
clientMutationId | ||
minimizedComment { | ||
isMinimized | ||
minimizedReason | ||
} | ||
`) | ||
if (resp.errors) { | ||
throw new Error(`${resp.errors[0].message}`) | ||
} | ||
} catch (err) { | ||
throw new Error(err) | ||
}`; | ||
|
||
const variables = { | ||
nodeId: nodeId, | ||
}; | ||
|
||
try { | ||
await github.graphql(mutation, variables); | ||
} catch (error) { | ||
throw new Error(`Error in minimizeIssueComment() function: ${error}`); | ||
} | ||
} | ||
|
||
module.exports = hideComment | ||
module.exports = minimizeIssueComment; |
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