0
0

Refactoring

This commit is contained in:
syuilo 2019-02-05 01:31:02 +09:00
parent 1d814ba0e1
commit 5410efe9ca
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69

View File

@ -50,29 +50,29 @@ export default Vue.extend({
this.isFavorited ? { this.isFavorited ? {
icon: 'star', icon: 'star',
text: this.$t('unfavorite'), text: this.$t('unfavorite'),
action: this.unfavorite action: () => this.toggleFavorite(false)
} : { } : {
icon: 'star', icon: 'star',
text: this.$t('favorite'), text: this.$t('favorite'),
action: this.favorite action: () => this.toggleFavorite(true)
}, },
this.note.userId != this.$store.state.i.id ? this.isWatching ? { this.note.userId != this.$store.state.i.id ? this.isWatching ? {
icon: faEyeSlash, icon: faEyeSlash,
text: this.$t('unwatch'), text: this.$t('unwatch'),
action: this.unwatch action: () => this.toggleWatch(false)
} : { } : {
icon: faEye, icon: faEye,
text: this.$t('watch'), text: this.$t('watch'),
action: this.watch action: () => this.toggleWatch(true)
} : undefined, } : undefined,
this.note.userId == this.$store.state.i.id ? (this.$store.state.i.pinnedNoteIds || []).includes(this.note.id) ? { this.note.userId == this.$store.state.i.id ? (this.$store.state.i.pinnedNoteIds || []).includes(this.note.id) ? {
icon: 'thumbtack', icon: 'thumbtack',
text: this.$t('unpin'), text: this.$t('unpin'),
action: this.unpin action: () => this.togglePin(false)
} : { } : {
icon: 'thumbtack', icon: 'thumbtack',
text: this.$t('pin'), text: this.$t('pin'),
action: this.pin action: () => this.togglePin(true)
} : undefined, } : undefined,
null, null,
this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin || this.$store.state.i.isModerator ? { this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin || this.$store.state.i.isModerator ? {
@ -117,8 +117,8 @@ export default Vue.extend({
}); });
}, },
pin() { togglePin(pin: boolean) {
this.$root.api('i/pin', { this.$root.api(pin ? 'i/pin' : 'i/unpin', {
noteId: this.note.id noteId: this.note.id
}).then(() => { }).then(() => {
this.$root.dialog({ this.$root.dialog({
@ -129,14 +129,6 @@ export default Vue.extend({
}); });
}, },
unpin() {
this.$root.api('i/unpin', {
noteId: this.note.id
}).then(() => {
this.destroyDom();
});
},
del() { del() {
this.$root.dialog({ this.$root.dialog({
type: 'warning', type: 'warning',
@ -153,8 +145,8 @@ export default Vue.extend({
}); });
}, },
favorite() { toggleFavorite(favorite: boolean) {
this.$root.api('notes/favorites/create', { this.$root.api(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
noteId: this.note.id noteId: this.note.id
}).then(() => { }).then(() => {
this.$root.dialog({ this.$root.dialog({
@ -165,32 +157,8 @@ export default Vue.extend({
}); });
}, },
unfavorite() { toggleWatch(watch: boolean) {
this.$root.api('notes/favorites/delete', { this.$root.api(watch ? 'notes/watching/create' : 'notes/watching/delete', {
noteId: this.note.id
}).then(() => {
this.$root.dialog({
type: 'success',
splash: true
});
this.destroyDom();
});
},
watch() {
this.$root.api('notes/watching/create', {
noteId: this.note.id
}).then(() => {
this.$root.dialog({
type: 'success',
splash: true
});
this.destroyDom();
});
},
unwatch() {
this.$root.api('notes/watching/delete', {
noteId: this.note.id noteId: this.note.id
}).then(() => { }).then(() => {
this.$root.dialog({ this.$root.dialog({