summaryrefslogtreecommitdiff
path: root/src/client/components
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-04-16 00:13:20 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-04-16 00:13:20 +0900
commitef6b370d0e482e59b9a4747d543afa4b4a465367 (patch)
treef83c59e6e9de9f95809fffd25ce3fab03d066a8b /src/client/components
parentfix bug (diff)
downloadsharkey-ef6b370d0e482e59b9a4747d543afa4b4a465367.tar.gz
sharkey-ef6b370d0e482e59b9a4747d543afa4b4a465367.tar.bz2
sharkey-ef6b370d0e482e59b9a4747d543afa4b4a465367.zip
Improve usability
Diffstat (limited to 'src/client/components')
-rw-r--r--src/client/components/post-form.vue48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/client/components/post-form.vue b/src/client/components/post-form.vue
index ce79f34d62..4c6a9ebc95 100644
--- a/src/client/components/post-form.vue
+++ b/src/client/components/post-form.vue
@@ -34,6 +34,7 @@
<button @click="addVisibleUser" class="_buttonPrimary"><Fa :icon="faPlus" fixed-width/></button>
</div>
</div>
+ <MkInfo warn v-if="hasNotSpecifiedMentions" class="hasNotSpecifiedMentions">{{ $ts.notSpecifiedMentionWarning }} - <button class="_textButton" @click="addMissingMention()">{{ $ts.add }}</button></MkInfo>
<input v-show="useCw" ref="cw" class="cw" v-model="cw" :placeholder="$ts.annotation" @keydown="onKeydown">
<textarea v-model="text" class="text" :class="{ withCw: useCw }" ref="text" :disabled="posting" :placeholder="placeholder" @keydown="onKeydown" @paste="onPaste" @compositionupdate="onCompositionUpdate" @compositionend="onCompositionEnd" />
<XPostFormAttaches class="attaches" :files="files" @updated="updateFiles" @detach="detachFile" @changeSensitive="updateFileSensitive" @changeName="updateFileName"/>
@@ -71,12 +72,14 @@ import { selectFile } from '@client/scripts/select-file';
import { notePostInterruptors, postFormActions } from '@client/store';
import { isMobile } from '@client/scripts/is-mobile';
import { throttle } from 'throttle-debounce';
+import MkInfo from '@client/components/ui/info.vue';
export default defineComponent({
components: {
XNotePreview,
XPostFormAttaches: defineAsyncComponent(() => import('./post-form-attaches.vue')),
- XPollEditor: defineAsyncComponent(() => import('./poll-editor.vue'))
+ XPollEditor: defineAsyncComponent(() => import('./poll-editor.vue')),
+ MkInfo,
},
inject: ['modal'],
@@ -143,6 +146,7 @@ export default defineComponent({
autocomplete: null,
draghover: false,
quoteId: null,
+ hasNotSpecifiedMentions: false,
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]'),
imeText: '',
typing: throttle(3000, () => {
@@ -214,6 +218,18 @@ export default defineComponent({
}
},
+ watch: {
+ text() {
+ this.checkMissingMention();
+ },
+ visibleUsers: {
+ handler() {
+ this.checkMissingMention();
+ },
+ deep: true
+ }
+ },
+
mounted() {
if (this.initialText) {
this.text = this.initialText;
@@ -338,6 +354,32 @@ export default defineComponent({
this.$watch('localOnly', () => this.saveDraft());
},
+ checkMissingMention() {
+ if (this.visibility === 'specified') {
+ const ast = mfm.parse(this.text);
+
+ for (const x of extractMentions(ast)) {
+ if (!this.visibleUsers.some(u => (u.username === x.username) && (u.host == x.host))) {
+ this.hasNotSpecifiedMentions = true;
+ return;
+ }
+ }
+ this.hasNotSpecifiedMentions = false;
+ }
+ },
+
+ addMissingMention() {
+ const ast = mfm.parse(this.text);
+
+ for (const x of extractMentions(ast)) {
+ if (!this.visibleUsers.some(u => (u.username === x.username) && (u.host == x.host))) {
+ os.api('users/show', { username: x.username, host: x.host }).then(user => {
+ this.visibleUsers.push(user);
+ });
+ }
+ }
+ },
+
togglePoll() {
if (this.poll) {
this.poll = null;
@@ -741,6 +783,10 @@ export default defineComponent({
}
}
+ > .hasNotSpecifiedMentions {
+ margin: 0 20px 16px 20px;
+ }
+
> .cw,
> .text {
display: block;