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

Add an example of updating modal #1142

Merged
merged 9 commits into from Feb 10, 2024
Merged

Conversation

KouWakai
Copy link
Contributor

@KouWakai KouWakai commented Dec 13, 2022

Hi!! I added updating modal example

since I wanted to know how could I handle updating modal in examples.

@KouWakai KouWakai changed the title Add example of updating modal Add an example of updating modal Dec 13, 2022
@KouWakai KouWakai marked this pull request as draft December 13, 2022 06:44
@KouWakai KouWakai marked this pull request as ready for review December 13, 2022 06:44
@kanata2 kanata2 added the example about example codes label Dec 14, 2022
@kanata2 kanata2 self-requested a review December 14, 2022 06:35
examples/modal/modal.go Outdated Show resolved Hide resolved
examples/modal/modal.go Outdated Show resolved Hide resolved
examples/modal/modal.go Outdated Show resolved Hide resolved
@kanata2 kanata2 added the feedback given When a review has been conducted and awaiting the response from the comitter(s) label Dec 21, 2022
@KouWakai
Copy link
Contributor Author

Thank you for feedback:pray:
I would modify codes to the suggestion

KouWakai and others added 3 commits December 25, 2022 13:24
Co-authored-by: Naoki Kanatani <k12naoki@gmail.com>
…erError

Co-authored-by: Naoki Kanatani <k12naoki@gmail.com>
// update modal sample
switch i.Type {
//update when interaction type is view_submission
case slack.InteractionTypeViewSubmission:

Choose a reason for hiding this comment

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

I couldn't get api.UpdateView to work under this event. I had to use slack.InteractionTypeBlockActions e.g block_action. Is this working for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback,I would check that.

Copy link
Contributor Author

@KouWakai KouWakai Aug 15, 2023

Choose a reason for hiding this comment

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

It's working but modal closes right after update.

I think this is caused by slack server.
after update modal,app respond http status 200 to slack server and the server see it as over

I'v been running this code on local and connect via ngrok and this happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

by adding time.Sleep(time.Second * 2) after api.UpdateView you can prevent sending http 200 and can see updated modal.

	case slack.InteractionTypeViewSubmission:
		//you can use any modal you want to show to users just like creating modal.
		updateModal := updateModal()
		// You must set one of external_id or view_id and you can use hash for avoiding race condition.
		// More details: https://api.slack.com/surfaces/modals/using#updating_apis
		_, err := api.UpdateView(updateModal, "", i.View.Hash, i.View.ID)
		time.Sleep(time.Second * 2)
		if err != nil {
			fmt.Printf("Error updating view: %s", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kanata2 @charlesoconor
sorry for kept you waiting,could you review this code?

@github-actions
Copy link

github-actions bot commented May 8, 2023

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale label May 8, 2023
@github-actions
Copy link

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this May 22, 2023
@kanata2 kanata2 reopened this May 22, 2023
@kanata2 kanata2 added needs review and removed stale feedback given When a review has been conducted and awaiting the response from the comitter(s) labels May 22, 2023
Copy link
Member

@parsley42 parsley42 left a comment

Choose a reason for hiding this comment

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

Even if this example isn't perfect, it's an expansion of what we had before.

@parsley42 parsley42 closed this Feb 10, 2024
@parsley42 parsley42 reopened this Feb 10, 2024
@parsley42 parsley42 merged commit 398133c into slack-go:master Feb 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example about example codes needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants