Merge branch 'develop'

This commit is contained in:
syuilo
2019-05-07 18:56:33 +09:00
25 changed files with 979 additions and 195 deletions

View File

@ -21,7 +21,7 @@ export default class Stream extends EventEmitter {
const user = os.store.state.i;
this.stream = new ReconnectingWebsocket(wsUrl + (user ? `?i=${user.token}` : ''));
this.stream = new ReconnectingWebsocket(wsUrl + (user ? `?i=${user.token}` : ''), '', { minReconnectionDelay: 1 }); // https://github.com/pladaria/reconnecting-websocket/issues/91
this.stream.addEventListener('open', this.onOpen);
this.stream.addEventListener('close', this.onClose);
this.stream.addEventListener('message', this.onMessage);

View File

@ -200,6 +200,7 @@ export default Vue.extend({
// 通信を取りこぼしてもいいように定期的にポーリングさせる
if (this.game.isStarted && !this.game.isEnded) {
this.pollingClock = setInterval(() => {
if (this.game.isEnded) return;
const crc32 = CRC32.str(this.logs.map(x => x.pos.toString()).join(''));
this.connection.send('check', {
crc32: crc32

View File

@ -230,7 +230,7 @@ export default Vue.extend({
this.game.map = Object.values(maps).find(x => x.name == this.mapName).data;
}
this.$forceUpdate();
this.updateSettings();
this.updateSettings('map');
},
onPixelClick(pos, pixel) {

View File

@ -10,7 +10,7 @@
<span>{{ $t('password') }}</span>
<template #prefix><fa icon="lock"/></template>
</ui-input>
<ui-input v-if="user && user.twoFactorEnabled" v-model="token" type="number" required>
<ui-input v-if="user && user.twoFactorEnabled" v-model="token" type="text" pattern="^[0-9]{6}$" autocomplete="off" spellcheck="false" required>
<span>{{ $t('@.2fa') }}</span>
<template #prefix><fa icon="gavel"/></template>
</ui-input>

View File

@ -5,10 +5,9 @@
<span class="label" ref="label"><slot name="label"></slot></span>
<div class="prefix" ref="prefix"><slot name="prefix"></slot></div>
<select ref="input"
:value="v"
v-model="v"
:required="required"
:disabled="disabled"
@input="$emit('input', $event.target.value)"
@focus="focused = true"
@blur="focused = false"
>
@ -56,20 +55,22 @@ export default Vue.extend({
},
data() {
return {
v: this.value,
focused: false
};
},
computed: {
v: {
get() {
return this.value;
},
set(v) {
this.$emit('input', v);
}
},
filled(): boolean {
return this.v != '' && this.v != null;
}
},
watch: {
value(v) {
this.v = v;
}
},
mounted() {
if (this.$refs.prefix) {
this.$refs.label.style.left = (this.$refs.prefix.offsetLeft + this.$refs.prefix.offsetWidth) + 'px';

View File

@ -44,6 +44,8 @@ export type Source = {
clusterLimit?: number;
id: string;
outgoingAddressFamily?: 'ipv4' | 'ipv6' | 'dual';
};
/**

View File

@ -101,11 +101,18 @@ export default async (user: ILocalUser, url: string, object: any) => {
* Resolve host (with cached, asynchrony)
*/
async function resolveAddr(domain: string) {
const af = config.outgoingAddressFamily || 'ipv4';
const useV4 = af == 'ipv4' || af == 'dual';
const useV6 = af == 'ipv6' || af == 'dual';
const promises = [];
if (!useV4 && !useV6) throw 'No usable address family available';
if (useV4) promises.push(resolveAddrInner(domain, { family: 4 }));
if (useV6) promises.push(resolveAddrInner(domain, { family: 6 }));
// v4/v6で先に取得できた方を採用する
return await promiseAny([
resolveAddrInner(domain, { family: 4 }),
resolveAddrInner(domain, { family: 6 })
]);
return await promiseAny(promises);
}
function resolveAddrInner(domain: string, options: IRunOptions = {}): Promise<string> {

View File

@ -85,8 +85,8 @@ export default define(meta, async (ps, me) => {
case '-follower': query.orderBy('user.followersCount', 'ASC'); break;
case '+createdAt': query.orderBy('user.createdAt', 'DESC'); break;
case '-createdAt': query.orderBy('user.createdAt', 'ASC'); break;
case '+updatedAt': query.orderBy('user.updatedAt', 'DESC'); break;
case '-updatedAt': query.orderBy('user.updatedAt', 'ASC'); break;
case '+updatedAt': query.andWhere('user.updatedAt IS NOT NULL').orderBy('user.updatedAt', 'DESC'); break;
case '-updatedAt': query.andWhere('user.updatedAt IS NOT NULL').orderBy('user.updatedAt', 'ASC'); break;
default: query.orderBy('user.id', 'ASC'); break;
}

View File

@ -302,16 +302,13 @@ export default class extends Channel {
}
@autobind
private async check(crc32: string) {
private async check(crc32: string | number) {
const game = await ReversiGames.findOne(this.gameId!);
if (game == null) throw new Error('game not found');
if (!game.isStarted) return;
// 互換性のため
if (game.crc32 == null) return;
if (crc32 !== game.crc32) {
if (crc32.toString() !== game.crc32) {
this.send('rescue', await ReversiGames.pack(game, this.user));
}
}