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

Issue #305: add check if slack panel is visible to prevent unnecessar… #332

Open
wants to merge 4 commits into
base: release-1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,29 @@ require([

function getTemplate() {
var issueKey = Meta.get("issue-key");
if (issueKey) {
var $issuePanel = $("#slack-issue-panel");
var $spinner = $("#slack-issue-panel-spinner");
var $errors = $("#slack-issue-panel-errors");
$spinner.spin();
return $.ajax({
url: wrmContextPath() + "/slack/issuepanel/data/" + issueKey,
cache: false,
dataType: 'json',
type: "GET"
}).done(function (data) {
var template = JIRA.Templates.Slack.Project.IssuePanel.slackPanel(data);
$issuePanel.html(template);

issuePanelView = createIssuePanelView();
issuePanelView.on("ready", evaluateImmediateActions);
}).fail(function () {
$errors.append(formatter.I18n.getText("jira.plugins.slack.viewissue.panel.error.getting.data"));
}).always(function() {
$spinner.spinStop();
});
var $issuePanel = $("#slack-issue-panel");
if (!issueKey || !$issuePanel.length) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than modifying the whole function to be a no-op, I'd recommend to prevent calling this function altogether. It would be less changes and the logic flow would be clearer.

Copy link
Author

Choose a reason for hiding this comment

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

I basically just added another condition to the already existing one that checks for the issueKey. Because getTemplate() is called 2 times it would be more code moving the condition out of the function. But if you want I can do the check before each function call.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. I agree. Then it may stay as it is.

}
var $spinner = $("#slack-issue-panel-spinner");
var $errors = $("#slack-issue-panel-errors");
$spinner.spin();
return $.ajax({
url: wrmContextPath() + "/slack/issuepanel/data/" + issueKey,
cache: false,
dataType: 'json',
type: "GET"
}).done(function (data) {
var template = JIRA.Templates.Slack.Project.IssuePanel.slackPanel(data);
$issuePanel.html(template);

issuePanelView = createIssuePanelView();
issuePanelView.on("ready", evaluateImmediateActions);
}).fail(function () {
$errors.append(formatter.I18n.getText("jira.plugins.slack.viewissue.panel.error.getting.data"));
}).always(function() {
$spinner.spinStop();
});
}

$(function () {
Expand Down
Loading