mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 13:31:44 +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",
|
classes: "btn-primary",
|
||||||
action: "back",
|
action: "back",
|
||||||
key: "errors.buttons.back"
|
key: "errors.buttons.back"
|
||||||
|
@ -28,11 +31,13 @@ export default Ember.Controller.extend({
|
||||||
lastTransition: null,
|
lastTransition: null,
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
isNetwork: function() {
|
isNetwork() {
|
||||||
// never made it on the wire
|
// never made it on the wire
|
||||||
if (this.get("thrown.readyState") === 0) return true;
|
if (this.get("thrown.readyState") === 0) return true;
|
||||||
|
|
||||||
// timed out
|
// timed out
|
||||||
if (this.get("thrown.jqTextStatus") === "timeout") return true;
|
if (this.get("thrown.jqTextStatus") === "timeout") return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -47,9 +52,10 @@ export default Ember.Controller.extend({
|
||||||
networkFixed: false,
|
networkFixed: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
||||||
_init: function() {
|
@on("init")
|
||||||
|
_init() {
|
||||||
this.set("loading", false);
|
this.set("loading", false);
|
||||||
}.on("init"),
|
},
|
||||||
|
|
||||||
@computed("isNetwork", "isServer", "isUnknown")
|
@computed("isNetwork", "isServer", "isUnknown")
|
||||||
reason() {
|
reason() {
|
||||||
|
@ -99,16 +105,16 @@ export default Ember.Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
back: function() {
|
back() {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
},
|
},
|
||||||
|
|
||||||
tryLoading: function() {
|
tryLoading() {
|
||||||
this.set("loading", true);
|
this.set("loading", true);
|
||||||
var self = this;
|
|
||||||
Ember.run.schedule("afterRender", function() {
|
Ember.run.schedule("afterRender", () => {
|
||||||
self.get("lastTransition").retry();
|
this.lastTransition.retry();
|
||||||
self.set("loading", false);
|
this.set("loading", false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user