Merge pull request #3681 from thelounge/xpaw/remove-vue-filter

Remove the only use of Vue.filter
This commit is contained in:
Pavel Djundik 2020-01-09 21:14:10 +02:00 committed by GitHub
commit 2e49175840
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 11 deletions

View file

@ -8,7 +8,7 @@
:data-type="message.type" :data-type="message.type"
:data-from="message.from && message.from.nick" :data-from="message.from && message.from.nick"
> >
<span :aria-label="message.time | localetime" class="time tooltipped tooltipped-e" <span :aria-label="messageTimeLocale" class="time tooltipped tooltipped-e"
>{{ messageTime }} >{{ messageTime }}
</span> </span>
<template v-if="message.type === 'unhandled'"> <template v-if="message.type === 'unhandled'">
@ -78,6 +78,7 @@
<script> <script>
const constants = require("../js/constants"); const constants = require("../js/constants");
import localetime from "../js/helpers/localetime";
import dayjs from "dayjs"; import dayjs from "dayjs";
import Username from "./Username.vue"; import Username from "./Username.vue";
import LinkPreview from "./LinkPreview.vue"; import LinkPreview from "./LinkPreview.vue";
@ -106,6 +107,9 @@ export default {
return dayjs(this.message.time).format(format); return dayjs(this.message.time).format(format);
}, },
messageTimeLocale() {
return localetime(this.message.time);
},
messageComponent() { messageComponent() {
return "message-" + this.message.type; return "message-" + this.message.type;
}, },

View file

@ -2,11 +2,12 @@
<span class="content"> <span class="content">
Topic set by Topic set by
<Username :user="message.from" /> <Username :user="message.from" />
on {{ message.when | localetime }} on {{ messageTimeLocale }}
</span> </span>
</template> </template>
<script> <script>
import localetime from "../../js/helpers/localetime";
import Username from "../Username.vue"; import Username from "../Username.vue";
export default { export default {
@ -18,5 +19,10 @@ export default {
network: Object, network: Object,
message: Object, message: Object,
}, },
computed: {
messageTimeLocale() {
return localetime(this.message.when);
},
},
}; };
</script> </script>

View file

@ -90,18 +90,19 @@
<template v-if="message.whois.logonTime"> <template v-if="message.whois.logonTime">
<dt>Connected at:</dt> <dt>Connected at:</dt>
<dd>{{ message.whois.logonTime | localetime }}</dd> <dd>{{ localetime(message.whois.logonTime) }}</dd>
</template> </template>
<template v-if="message.whois.idle"> <template v-if="message.whois.idle">
<dt>Idle since:</dt> <dt>Idle since:</dt>
<dd>{{ message.whois.idleTime | localetime }}</dd> <dd>{{ localetime(message.whois.idleTime) }}</dd>
</template> </template>
</dl> </dl>
</span> </span>
</template> </template>
<script> <script>
import localetime from "../../js/helpers/localetime";
import ParsedMessage from "../ParsedMessage.vue"; import ParsedMessage from "../ParsedMessage.vue";
import Username from "../Username.vue"; import Username from "../Username.vue";
@ -115,5 +116,10 @@ export default {
network: Object, network: Object,
message: Object, message: Object,
}, },
methods: {
localetime(date) {
return localetime(date);
},
},
}; };
</script> </script>

View file

@ -12,7 +12,7 @@
<em>Currently active</em> <em>Currently active</em>
</p> </p>
<p v-else> <p v-else>
Last used on <time>{{ session.lastUse | localetime }}</time> Last used on <time>{{ lastUse }}</time>
</p> </p>
</template> </template>
</div> </div>
@ -26,6 +26,7 @@
</template> </template>
<script> <script>
import localetime from "../js/helpers/localetime";
import Auth from "../js/auth"; import Auth from "../js/auth";
import socket from "../js/socket"; import socket from "../js/socket";
@ -34,6 +35,11 @@ export default {
props: { props: {
session: Object, session: Object,
}, },
computed: {
lastUse() {
return localetime(this.session.lastUse);
},
},
methods: { methods: {
signOut() { signOut() {
if (!this.session.current) { if (!this.session.current) {

View file

@ -11,18 +11,25 @@
<tr v-for="ban in channel.data" :key="ban.hostmask"> <tr v-for="ban in channel.data" :key="ban.hostmask">
<td class="hostmask">{{ ban.hostmask }}</td> <td class="hostmask">{{ ban.hostmask }}</td>
<td class="banned_by">{{ ban.banned_by }}</td> <td class="banned_by">{{ ban.banned_by }}</td>
<td class="banned_at">{{ ban.banned_at | localetime }}</td> <td class="banned_at">{{ localetime(ban.banned_at) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</template> </template>
<script> <script>
import localetime from "../../js/helpers/localetime";
export default { export default {
name: "ListBans", name: "ListBans",
props: { props: {
network: Object, network: Object,
channel: Object, channel: Object,
}, },
methods: {
localetime(date) {
return localetime(date);
},
},
}; };
</script> </script>

View file

@ -9,18 +9,25 @@
<tbody> <tbody>
<tr v-for="user in channel.data" :key="user.hostmask"> <tr v-for="user in channel.data" :key="user.hostmask">
<td class="hostmask">{{ user.hostmask }}</td> <td class="hostmask">{{ user.hostmask }}</td>
<td class="when">{{ user.when | localetime }}</td> <td class="when">{{ localetime(user.when) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</template> </template>
<script> <script>
import localetime from "../../js/helpers/localetime";
export default { export default {
name: "ListIgnored", name: "ListIgnored",
props: { props: {
network: Object, network: Object,
channel: Object, channel: Object,
}, },
methods: {
localetime(date) {
return localetime(date);
},
},
}; };
</script> </script>

View file

@ -11,18 +11,25 @@
<tr v-for="invite in channel.data" :key="invite.hostmask"> <tr v-for="invite in channel.data" :key="invite.hostmask">
<td class="hostmask">{{ invite.hostmask }}</td> <td class="hostmask">{{ invite.hostmask }}</td>
<td class="invitened_by">{{ invite.invited_by }}</td> <td class="invitened_by">{{ invite.invited_by }}</td>
<td class="invitened_at">{{ invite.invited_at | localetime }}</td> <td class="invitened_at">{{ localetime(invite.invited_at) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</template> </template>
<script> <script>
import localetime from "../../js/helpers/localetime";
export default { export default {
name: "ListInvites", name: "ListInvites",
props: { props: {
network: Object, network: Object,
channel: Object, channel: Object,
}, },
methods: {
localetime(date) {
return localetime(date);
},
},
}; };
</script> </script>

View file

@ -5,13 +5,10 @@ const constants = require("./constants");
import Vue from "vue"; import Vue from "vue";
import store from "./store"; import store from "./store";
import App from "../components/App.vue"; import App from "../components/App.vue";
import localetime from "./helpers/localetime";
import storage from "./localStorage"; import storage from "./localStorage";
import {router, navigate} from "./router"; import {router, navigate} from "./router";
import socket from "./socket"; import socket from "./socket";
Vue.filter("localetime", localetime);
import "./socket-events"; import "./socket-events";
import "./webpush"; import "./webpush";
import "./keybinds"; import "./keybinds";