mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 10:12:32 +08:00
REFACTOR: exception controller (#7675)
This commit is contained in:
parent
43a46df075
commit
0c5498c9a4
|
@ -1,6 +1,9 @@
|
|||
import computed from "ember-addons/ember-computed-decorators";
|
||||
import {
|
||||
on,
|
||||
default as computed
|
||||
} from "ember-addons/ember-computed-decorators";
|
||||
|
||||
var ButtonBackBright = {
|
||||
const ButtonBackBright = {
|
||||
classes: "btn-primary",
|
||||
action: "back",
|
||||
key: "errors.buttons.back"
|
||||
|
@ -28,11 +31,13 @@ export default Ember.Controller.extend({
|
|||
lastTransition: null,
|
||||
|
||||
@computed
|
||||
isNetwork: function() {
|
||||
isNetwork() {
|
||||
// never made it on the wire
|
||||
if (this.get("thrown.readyState") === 0) return true;
|
||||
|
||||
// timed out
|
||||
if (this.get("thrown.jqTextStatus") === "timeout") return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
|
@ -47,9 +52,10 @@ export default Ember.Controller.extend({
|
|||
networkFixed: false,
|
||||
loading: false,
|
||||
|
||||
_init: function() {
|
||||
@on("init")
|
||||
_init() {
|
||||
this.set("loading", false);
|
||||
}.on("init"),
|
||||
},
|
||||
|
||||
@computed("isNetwork", "isServer", "isUnknown")
|
||||
reason() {
|
||||
|
@ -99,16 +105,16 @@ export default Ember.Controller.extend({
|
|||
},
|
||||
|
||||
actions: {
|
||||
back: function() {
|
||||
back() {
|
||||
window.history.back();
|
||||
},
|
||||
|
||||
tryLoading: function() {
|
||||
tryLoading() {
|
||||
this.set("loading", true);
|
||||
var self = this;
|
||||
Ember.run.schedule("afterRender", function() {
|
||||
self.get("lastTransition").retry();
|
||||
self.set("loading", false);
|
||||
|
||||
Ember.run.schedule("afterRender", () => {
|
||||
this.lastTransition.retry();
|
||||
this.set("loading", false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user