forked from FoundKeyGang/FoundKey
Refactoring
This commit is contained in:
parent
1d814ba0e1
commit
5410efe9ca
1 changed files with 12 additions and 44 deletions
|
@ -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({
|
||||||
|
|
Loading…
Reference in a new issue