Skip to content

Commit

Permalink
サーバーとの接続が過去に切断されていたらリロードボタンを出すように
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Jan 31, 2020
1 parent 46eb81e commit 2e14898
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 16 deletions.
3 changes: 3 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ common/views/components/stream-indicator.vue:
connecting: "Connecting"
reconnecting: "Reconnecting"
connected: "Connected"
has-disconnected: "Connection to server was lost in the past"
reload: "Reload"
ignore: "Do nothing"
common/views/components/notification-settings.vue:
title: "Notifications"
mark-as-read-all-notifications: "Mark all notifications as read"
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ common/views/components/stream-indicator.vue:
connecting: "接続中"
reconnecting: "再接続中"
connected: "接続完了"
has-disconnected: "サーバーから切断されていました"
reload: "リロードする"
ignore: "なにもしない"

common/views/components/notification-settings.vue:
title: "通知"
Expand Down
74 changes: 58 additions & 16 deletions src/client/app/common/views/components/stream-indicator.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
<template>
<div class="mk-stream-indicator">
<p v-if="stream.state == 'initializing'">
<fa icon="spinner" pulse/>
<span>{{ $t('connecting') }}<mk-ellipsis/></span>
</p>
<p v-if="stream.state == 'reconnecting'">
<fa icon="spinner" pulse/>
<span>{{ $t('reconnecting') }}<mk-ellipsis/></span>
</p>
<p v-if="stream.state == 'connected'">
<fa icon="check"/>
<span>{{ $t('connected') }}</span>
</p>
<div>
<div class="disconnect-notify" v-if="stream.state == 'connected' && hasDisconnected" @click="hasDisconnected = false">
<div><fa icon="exclamation-triangle"/> {{ $t('has-disconnected') }}</div>
<div class="command">
<button @click="reload">{{ $t('reload') }}</button>
<button>{{ $t('ignore') }}</button>
</div>
</div>
<div class="mk-stream-indicator" ref="indicator">
<p v-if="stream.state == 'initializing'">
<fa icon="spinner" pulse/>
<span>{{ $t('connecting') }}<mk-ellipsis/></span>
</p>
<p v-if="stream.state == 'reconnecting'">
<fa icon="spinner" pulse/>
<span>{{ $t('reconnecting') }}<mk-ellipsis/></span>
</p>
<p v-if="stream.state == 'connected'">
<fa icon="check"/>
<span>{{ $t('connected') }}</span>
</p>
</div>
</div>
</template>

Expand All @@ -22,6 +31,11 @@ import anime from 'animejs';
export default Vue.extend({
i18n: i18n('common/views/components/stream-indicator.vue'),
data() {
return {
hasDisconnected: false,
}
},
computed: {
stream() {
return this.$root.stream;
Expand All @@ -45,26 +59,54 @@ export default Vue.extend({
onConnected() {
setTimeout(() => {
anime({
targets: this.$el,
targets: this.$refs.indicator,
opacity: 0,
easing: 'linear',
duration: 200
});
}, 1000);
},
onDisconnected() {
this.hasDisconnected = true;
anime({
targets: this.$el,
targets: this.$refs.indicator,
opacity: 1,
easing: 'linear',
duration: 100
});
}
},
reload() {
location.reload();
},
}
});
</script>

<style lang="stylus" scoped>
.disconnect-notify
position fixed
z-index 16385
bottom 8px
right 8px
margin 0
padding 6px 12px
font-size 0.9em
color #fff
background rgba(#000)
border-radius 4px
max-width 320px
> .command
display flex
justify-content space-around
> button
color #aaa
padding 0.7em
&:hover
color #ccc
.mk-stream-indicator
pointer-events none
position fixed
Expand Down

0 comments on commit 2e14898

Please sign in to comment.