Skip to content
Snippets Groups Projects
Unverified Commit 5410efe9 authored by syuilo's avatar syuilo
Browse files

Refactoring

parent 1d814ba0
No related branches found
No related tags found
No related merge requests found
......@@ -50,29 +50,29 @@ export default Vue.extend({
this.isFavorited ? {
icon: 'star',
text: this.$t('unfavorite'),
action: this.unfavorite
action: () => this.toggleFavorite(false)
} : {
icon: 'star',
text: this.$t('favorite'),
action: this.favorite
action: () => this.toggleFavorite(true)
},
this.note.userId != this.$store.state.i.id ? this.isWatching ? {
icon: faEyeSlash,
text: this.$t('unwatch'),
action: this.unwatch
action: () => this.toggleWatch(false)
} : {
icon: faEye,
text: this.$t('watch'),
action: this.watch
action: () => this.toggleWatch(true)
} : undefined,
this.note.userId == this.$store.state.i.id ? (this.$store.state.i.pinnedNoteIds || []).includes(this.note.id) ? {
icon: 'thumbtack',
text: this.$t('unpin'),
action: this.unpin
action: () => this.togglePin(false)
} : {
icon: 'thumbtack',
text: this.$t('pin'),
action: this.pin
action: () => this.togglePin(true)
} : undefined,
null,
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() {
this.$root.api('i/pin', {
togglePin(pin: boolean) {
this.$root.api(pin ? 'i/pin' : 'i/unpin', {
noteId: this.note.id
}).then(() => {
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() {
this.$root.dialog({
type: 'warning',
......@@ -153,32 +145,8 @@ export default Vue.extend({
});
},
favorite() {
this.$root.api('notes/favorites/create', {
noteId: this.note.id
}).then(() => {
this.$root.dialog({
type: 'success',
splash: true
});
this.destroyDom();
});
},
unfavorite() {
this.$root.api('notes/favorites/delete', {
noteId: this.note.id
}).then(() => {
this.$root.dialog({
type: 'success',
splash: true
});
this.destroyDom();
});
},
watch() {
this.$root.api('notes/watching/create', {
toggleFavorite(favorite: boolean) {
this.$root.api(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
noteId: this.note.id
}).then(() => {
this.$root.dialog({
......@@ -189,8 +157,8 @@ export default Vue.extend({
});
},
unwatch() {
this.$root.api('notes/watching/delete', {
toggleWatch(watch: boolean) {
this.$root.api(watch ? 'notes/watching/create' : 'notes/watching/delete', {
noteId: this.note.id
}).then(() => {
this.$root.dialog({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment