Commit 439b2fd655c4e2b043b509caf646206a3e60f528
display error on publish when message is too large
#456 #603 #640Matt McKegg committed on 10/18/2017, 2:28:32 AM
Parent: 957964085af70face2c01919aba9f5032f4fdd8f
Files changed
locales/en.json | changed |
modules/message/html/compose.js | changed |
locales/en.json | ||
---|---|---|
@@ -169,6 +169,7 @@ | ||
169 | 169 | "Blocked by": "Blocked by", |
170 | 170 | "However, this person should be able to see your posts.": "However, this person should be able to see your posts.", |
171 | 171 | "However, since they follow someone that follows you, they should be able to see your posts.": "However, since they follow someone that follows you, they should be able to see your posts.", |
172 | 172 | "They might not be able to see your posts either.": "They might not be able to see your posts either.", |
173 | - "However, since you follow someone that follows them, you should be able to see their latest posts.": "However, since you follow someone that follows them, you should be able to see their latest posts." | |
173 | + "However, since you follow someone that follows them, you should be able to see their latest posts.": "However, since you follow someone that follows them, you should be able to see their latest posts.", | |
174 | + "An error occured while publishing your message.": "An error occured while publishing your message." | |
174 | 175 | } |
modules/message/html/compose.js | ||
---|---|---|
@@ -180,20 +180,35 @@ | ||
180 | 180 | if (typeof prepublish === 'function') { |
181 | 181 | content = prepublish(content) |
182 | 182 | } |
183 | 183 | } catch (err) { |
184 | - publishing.set(false) | |
185 | - if (cb) cb(err) | |
186 | - else throw err | |
184 | + return done(err) | |
187 | 185 | } |
188 | 186 | |
189 | 187 | return api.message.async.publish(content, done) |
190 | 188 | |
191 | 189 | function done (err, msg) { |
192 | 190 | publishing.set(false) |
193 | - if (err) throw err | |
194 | - else if (msg) textArea.value = '' | |
195 | - if (cb) cb(err, msg) | |
191 | + if (err) { | |
192 | + if (cb) cb(err) | |
193 | + else { | |
194 | + showDialog({ | |
195 | + type: 'error', | |
196 | + title: i18n('Error'), | |
197 | + buttons: [i18n('OK')], | |
198 | + message: i18n('An error occured while publishing your message.'), | |
199 | + detail: err.message | |
200 | + }) | |
201 | + } | |
202 | + } else { | |
203 | + textArea.value = '' | |
204 | + if (cb) cb(null, msg) | |
205 | + } | |
196 | 206 | } |
197 | 207 | } |
198 | 208 | }) |
199 | 209 | } |
210 | + | |
211 | +function showDialog (opts) { | |
212 | + var electron = require('electron') | |
213 | + electron.remote.dialog.showMessageBox(electron.remote.getCurrentWindow(), opts) | |
214 | +} |
Built with git-ssb-web