summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-01-18 16:46:56 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-01-18 16:46:56 +0900
commit9fc1cc525590fc94431eb6b4beccfeb75acf08bb (patch)
tree9be014dbe5751c215ae6375a611ab1814b2b58cc /src
parentanimejs 3.xに対応 (diff)
downloadmisskey-9fc1cc525590fc94431eb6b4beccfeb75acf08bb.tar.gz
misskey-9fc1cc525590fc94431eb6b4beccfeb75acf08bb.tar.bz2
misskey-9fc1cc525590fc94431eb6b4beccfeb75acf08bb.zip
[Client] Drop apiViaStream option
Resolve #3911
Diffstat (limited to 'src')
-rw-r--r--src/client/app/admin/views/dashboard.vue2
-rw-r--r--src/client/app/common/views/components/signin.vue2
-rw-r--r--src/client/app/common/views/components/signup.vue4
-rw-r--r--src/client/app/desktop/views/components/settings.vue12
-rw-r--r--src/client/app/mios.ts86
-rw-r--r--src/client/app/store.ts1
6 files changed, 36 insertions, 71 deletions
diff --git a/src/client/app/admin/views/dashboard.vue b/src/client/app/admin/views/dashboard.vue
index 9fb97f2ef9..aa4431e438 100644
--- a/src/client/app/admin/views/dashboard.vue
+++ b/src/client/app/admin/views/dashboard.vue
@@ -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;
});
}
diff --git a/src/client/app/common/views/components/signin.vue b/src/client/app/common/views/components/signin.vue
index 7efbde38b2..724efdfc18 100644
--- a/src/client/app/common/views/components/signin.vue
+++ b/src/client/app/common/views/components/signin.vue
@@ -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(() => {
diff --git a/src/client/app/common/views/components/signup.vue b/src/client/app/common/views/components/signup.vue
index f7c4f4bf1e..f38aaad8ed 100644
--- a/src/client/app/common/views/components/signup.vue
+++ b/src/client/app/common/views/components/signup.vue
@@ -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();
});
diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue
index 5ffe69ef45..78f8d9ccd2 100644
--- a/src/client/app/desktop/views/components/settings.vue
+++ b/src/client/app/desktop/views/components/settings.vue
@@ -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 }); }
diff --git a/src/client/app/mios.ts b/src/client/app/mios.ts
index fad60f4137..dc550b6f70 100644
--- a/src/client/app/mios.ts
+++ b/src/client/app/mios.ts
@@ -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,66 +401,44 @@ 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;
+ // Append a credential
+ if (this.store.getters.isSignedIn) (data as any).i = this.store.state.i.token;
- 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);
- }
- });
+ const req = {
+ id: uuid(),
+ date: new Date(),
+ name: endpoint,
+ data,
+ res: null,
+ status: null
+ };
- 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;
+ if (this.debug) {
+ this.requests.push(req);
+ }
- const req = {
- id: uuid(),
- date: new Date(),
- name: endpoint,
- data,
- res: null,
- status: null
- };
+ // Send request
+ fetch(endpoint.indexOf('://') > -1 ? endpoint : `${apiUrl}/${endpoint}`, {
+ method: 'POST',
+ body: JSON.stringify(data),
+ credentials: endpoint === 'signin' ? 'include' : 'omit',
+ cache: 'no-cache'
+ }).then(async (res) => {
+ const body = res.status === 204 ? null : await res.json();
if (this.debug) {
- this.requests.push(req);
+ req.status = res.status;
+ req.res = body;
}
- // Send request
- fetch(endpoint.indexOf('://') > -1 ? endpoint : `${apiUrl}/${endpoint}`, {
- method: 'POST',
- body: JSON.stringify(data),
- credentials: endpoint === 'signin' ? 'include' : 'omit',
- cache: 'no-cache'
- }).then(async (res) => {
- const body = res.status === 204 ? null : await res.json();
-
- if (this.debug) {
- req.status = res.status;
- req.res = body;
- }
-
- if (res.status === 200) {
- resolve(body);
- } else if (res.status === 204) {
- resolve();
- } else {
- reject(body.error);
- }
- }).catch(reject);
- }
+ if (res.status === 200) {
+ resolve(body);
+ } else if (res.status === 204) {
+ resolve();
+ } else {
+ reject(body.error);
+ }
+ }).catch(reject);
});
promise.then(onFinally, onFinally);
diff --git a/src/client/app/store.ts b/src/client/app/store.ts
index 03fc9565d8..350826e5ef 100644
--- a/src/client/app/store.ts
+++ b/src/client/app/store.ts
@@ -47,7 +47,6 @@ const defaultSettings = {
const defaultDeviceSettings = {
reduceMotion: false,
- apiViaStream: true,
autoPopout: false,
darkmode: false,
darkTheme: 'dark',