[Client] Drop apiViaStream option

Resolve #3911
This commit is contained in:
syuilo 2019-01-18 16:46:56 +09:00
parent 4ba43b69b6
commit 9fc1cc5255
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
7 changed files with 36 additions and 74 deletions

View file

@ -870,9 +870,6 @@ desktop/views/components/settings.vue:
web-search-engine-desc: "例: https://www.google.com/?#q={{query}}"
auto-popout: "ウィンドウの自動ポップアウト"
auto-popout-desc: "ウィンドウが開かれるとき、ポップアウト(ブラウザ外に切り離す)可能なら自動でポップアウトします。この設定はブラウザに記憶されます。"
advanced: "詳細設定"
api-via-stream: "ストリームを経由したAPIリクエスト"
api-via-stream-desc: "この設定をオンにすると、websocket接続を経由してAPIリクエストが行われます(パフォーマンス向上が期待できます)。オフにすると、ネイティブの fetch APIが利用されます。この設定はこのデバイスのみ有効です。"
deck-nav: "デッキ内ナビゲーション"
deck-nav-desc: "デッキを使用しているとき、ナビゲーションが発生する際にページ遷移を行わずに一時的なカラムで受けるようにします。"
deck-default: "デッキをデフォルトのUIにする"

View file

@ -148,7 +148,7 @@ export default Vue.extend({
},
updateStats() {
this.$root.api('stats', {}, false, true).then(stats => {
this.$root.api('stats', {}, true).then(stats => {
this.stats = stats;
});
}

View file

@ -72,7 +72,7 @@ export default Vue.extend({
username: this.username,
password: this.password,
token: this.user && this.user.twoFactorEnabled ? this.token : undefined
}, true).then(res => {
}).then(res => {
localStorage.setItem('i', res.i);
location.reload();
}).catch(() => {

View file

@ -142,11 +142,11 @@ export default Vue.extend({
password: this.password,
invitationCode: this.invitationCode,
'g-recaptcha-response': this.meta.enableRecaptcha ? (window as any).grecaptcha.getResponse() : null
}, true).then(() => {
}).then(() => {
this.$root.api('signin', {
username: this.username,
password: this.password
}, true).then(res => {
}).then(res => {
localStorage.setItem('i', res.i);
location.reload();
});

View file

@ -32,13 +32,6 @@
<span slot="desc">{{ $t('auto-popout-desc') }}</span>
</ui-switch>
<ui-switch v-model="deckNav">{{ $t('deck-nav') }}<span slot="desc">{{ $t('deck-nav-desc') }}</span></ui-switch>
<details>
<summary>{{ $t('advanced') }}</summary>
<ui-switch v-model="apiViaStream">{{ $t('api-via-stream') }}
<span slot="desc">{{ $t('api-via-stream-desc') }}</span>
</ui-switch>
</details>
</section>
<section>
@ -333,11 +326,6 @@ export default Vue.extend({
set(value) { this.$store.commit('device/set', { key: 'reduceMotion', value }); }
},
apiViaStream: {
get() { return this.$store.state.device.apiViaStream; },
set(value) { this.$store.commit('device/set', { key: 'apiViaStream', value }); }
},
autoPopout: {
get() { return this.$store.state.device.autoPopout; },
set(value) { this.$store.commit('device/set', { key: 'autoPopout', value }); }

View file

@ -385,7 +385,7 @@ export default class MiOS extends EventEmitter {
* @param data
*/
@autobind
public api(endpoint: string, data: { [x: string]: any } = {}, forceFetch = false, silent = false): Promise<{ [x: string]: any }> {
public api(endpoint: string, data: { [x: string]: any } = {}, silent = false): Promise<{ [x: string]: any }> {
if (!silent) {
if (++pending === 1) {
spinner = document.createElement('div');
@ -401,27 +401,6 @@ export default class MiOS extends EventEmitter {
};
const promise = new Promise((resolve, reject) => {
const viaStream = this.stream && this.stream.state == 'connected' && this.store.state.device.apiViaStream && !forceFetch;
if (viaStream) {
const id = Math.random().toString().substr(2, 8);
this.stream.once(`api:${id}`, res => {
if (res == null || Object.keys(res).length == 0) {
resolve(null);
} else if (res.res) {
resolve(res.res);
} else {
reject(res.e);
}
});
this.stream.send('api', {
id: id,
ep: endpoint,
data: data
});
} else {
// Append a credential
if (this.store.getters.isSignedIn) (data as any).i = this.store.state.i.token;
@ -460,7 +439,6 @@ export default class MiOS extends EventEmitter {
reject(body.error);
}
}).catch(reject);
}
});
promise.then(onFinally, onFinally);

View file

@ -47,7 +47,6 @@ const defaultSettings = {
const defaultDeviceSettings = {
reduceMotion: false,
apiViaStream: true,
autoPopout: false,
darkmode: false,
darkTheme: 'dark',