(ctx context.Context)
| 137 | } |
| 138 | |
| 139 | func (a *App) onBeforeClose(ctx context.Context) bool { |
| 140 | a.mu.Lock() |
| 141 | modified := a.ProjectModified |
| 142 | a.mu.Unlock() |
| 143 | |
| 144 | if !modified { |
| 145 | return false |
| 146 | } |
| 147 | |
| 148 | wailsRuntime.EventsEmit(a.ctx, "close-confirm", nil) |
| 149 | result := <-a.closeConfirmChan |
| 150 | |
| 151 | switch result { |
| 152 | case "save": |
| 153 | if saveErr := a.SaveProject(); saveErr != nil { |
| 154 | wailsRuntime.MessageDialog(ctx, wailsRuntime.MessageDialogOptions{ |
| 155 | Type: wailsRuntime.ErrorDialog, |
| 156 | Title: "Error", |
| 157 | Message: "Failed to save project: " + saveErr.Error(), |
| 158 | }) |
| 159 | return true |
| 160 | } |
| 161 | return false |
| 162 | case "nosave": |
| 163 | return false |
| 164 | default: |
| 165 | return true |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | func (a *App) SubmitCloseAction(action string) { |
| 170 | select { |
nothing calls this directly
no test coverage detected