Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(messageEdit): only allow user to edit their own message #281

Merged
merged 2 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/tailored/messaging/message/Message.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
<UiUsername :username="from" :badge="$mock.users.filter(u => u.name === from)[0].badge" />
<TypographyText :text="$dayjs(message.at).from()" />
</div>
<TailoredMessagingMessageActions v-if="messageHover && !hideActions"
:setReplyChatbarContent="setReplyChatbarContent" :emojiReaction="emojiReaction" :editMessage="editMessage" />
<TailoredMessagingMessageActions
v-if="messageHover && !hideActions"
:setReplyChatbarContent="setReplyChatbarContent"
:emojiReaction="emojiReaction"
:editMessage="editMessage"
:messageOwner="this.$props.message.from" />
<VueMarkdown v-if="!messageEdit && message.type === 'text'" :source="message.payload" class="markdown" />
<UiImage v-else-if="message.type === 'image'" :source="message.payload.url" alt="" />
<!-- Only for video types we can't embed directly without doing something sketchy, like sending it to a server somewhere to extract the HTML5 video-->
Expand Down
5 changes: 3 additions & 2 deletions components/tailored/messaging/message/actions/Actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
<div
class="reply-command has-tooltip has-tooltip-primary"
:data-tooltip="$t('global.edit')"
v-if="messageOwner === accounts.details.textilePubkey"
@click="editMessage"
>
<edit-icon size="1x" :class="'control-icon'"
@click="editMessage" />
<edit-icon size="1x" :class="'control-icon'" />
</div>
<div
class="reply-command has-tooltip has-tooltip-primary"
Expand Down
6 changes: 5 additions & 1 deletion components/tailored/messaging/message/actions/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ export default Vue.extend({
type: Function,
default: () => () => {},
},
messageOwner: {
type: String,
required: true,
},
},
computed: {
...mapState(['ui']),
...mapState(['ui', 'accounts'])
},
})
</script>
Expand Down