mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-22 08:20:10 +00:00
お気に入りを解除できるように
This commit is contained in:
parent
1012b2b2c7
commit
719fac6480
4 changed files with 43 additions and 7 deletions
|
@ -363,6 +363,7 @@ common/views/components/note-menu.vue:
|
||||||
detail: "詳細"
|
detail: "詳細"
|
||||||
copy-link: "リンクをコピー"
|
copy-link: "リンクをコピー"
|
||||||
favorite: "お気に入り"
|
favorite: "お気に入り"
|
||||||
|
unfavorite: "お気に入り解除"
|
||||||
pin: "ピン留め"
|
pin: "ピン留め"
|
||||||
unpin: "ピン留め解除"
|
unpin: "ピン留め解除"
|
||||||
delete: "削除"
|
delete: "削除"
|
||||||
|
|
|
@ -22,11 +22,21 @@ export default Vue.extend({
|
||||||
icon: '%fa:link%',
|
icon: '%fa:link%',
|
||||||
text: '%i18n:@copy-link%',
|
text: '%i18n:@copy-link%',
|
||||||
action: this.copyLink
|
action: this.copyLink
|
||||||
}, null, {
|
}, null];
|
||||||
icon: '%fa:star%',
|
|
||||||
text: '%i18n:@favorite%',
|
if (this.note.isFavorited) {
|
||||||
action: this.favorite
|
items.push({
|
||||||
}];
|
icon: '%fa:star%',
|
||||||
|
text: '%i18n:@unfavorite%',
|
||||||
|
action: this.unfavorite
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
items.push({
|
||||||
|
icon: '%fa:star%',
|
||||||
|
text: '%i18n:@favorite%',
|
||||||
|
action: this.favorite
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (this.note.userId == this.$store.state.i.id) {
|
if (this.note.userId == this.$store.state.i.id) {
|
||||||
if ((this.$store.state.i.pinnedNoteIds || []).includes(this.note.id)) {
|
if ((this.$store.state.i.pinnedNoteIds || []).includes(this.note.id)) {
|
||||||
|
@ -45,6 +55,7 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin) {
|
if (this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin) {
|
||||||
|
items.push(null);
|
||||||
items.push({
|
items.push({
|
||||||
icon: '%fa:trash-alt R%',
|
icon: '%fa:trash-alt R%',
|
||||||
text: '%i18n:@delete%',
|
text: '%i18n:@delete%',
|
||||||
|
@ -110,6 +121,15 @@ export default Vue.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
unfavorite() {
|
||||||
|
(this as any).api('notes/favorites/delete', {
|
||||||
|
noteId: this.note.id
|
||||||
|
}).then(() => {
|
||||||
|
(this as any).os.new(Ok);
|
||||||
|
this.destroyDom();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
closed() {
|
closed() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.destroyDom();
|
this.destroyDom();
|
||||||
|
|
|
@ -75,7 +75,9 @@ export const pack = (
|
||||||
delete _favorite._id;
|
delete _favorite._id;
|
||||||
|
|
||||||
// Populate note
|
// Populate note
|
||||||
_favorite.note = await packNote(_favorite.noteId, me);
|
_favorite.note = await packNote(_favorite.noteId, me, {
|
||||||
|
detail: true
|
||||||
|
});
|
||||||
|
|
||||||
// (データベースの不具合などで)投稿が見つからなかったら
|
// (データベースの不具合などで)投稿が見つからなかったら
|
||||||
if (_favorite.note == null) {
|
if (_favorite.note == null) {
|
||||||
|
|
|
@ -358,8 +358,8 @@ export const pack = async (
|
||||||
})(_note.poll);
|
})(_note.poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch my reaction
|
|
||||||
if (meId) {
|
if (meId) {
|
||||||
|
// Fetch my reaction
|
||||||
_note.myReaction = (async () => {
|
_note.myReaction = (async () => {
|
||||||
const reaction = await Reaction
|
const reaction = await Reaction
|
||||||
.findOne({
|
.findOne({
|
||||||
|
@ -374,6 +374,19 @@ export const pack = async (
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// isFavorited
|
||||||
|
_note.isFavorited = (async () => {
|
||||||
|
const favorite = await Favorite
|
||||||
|
.count({
|
||||||
|
userId: meId,
|
||||||
|
noteId: id
|
||||||
|
}, {
|
||||||
|
limit: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
return favorite === 1;
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue