Show errror dialog when audio recording not supported

Better handling of issue #92.
This commit is contained in:
N-Pex 2021-05-25 12:04:51 +02:00
parent c9f237d8c1
commit b7b1f201e8
2 changed files with 70 additions and 18 deletions

View file

@ -167,7 +167,9 @@
"voice_recorder": { "voice_recorder": {
"swipe_to_cancel": "Swipe to cancel", "swipe_to_cancel": "Swipe to cancel",
"release_to_cancel": "Release to cancel", "release_to_cancel": "Release to cancel",
"failed_to_record": "Failed to record audio" "failed_to_record": "Failed to record audio",
"not_supported_title": "Not supported",
"not_supported_text": "Unfortunately, this browser does not support audio recording."
}, },
"power_level": { "power_level": {
"admin": "administrator", "admin": "administrator",

View file

@ -135,7 +135,11 @@
<v-row class="ma-0 pa-0"> <v-row class="ma-0 pa-0">
<div v-if="replyToEvent"> <div v-if="replyToEvent">
{{$t('message.replying_to_event',{message: replyToEvent.getContent().body}) }} {{
$t("message.replying_to_event", {
message: replyToEvent.getContent().body,
})
}}
</div> </div>
<!-- CONTACT IS TYPING --> <!-- CONTACT IS TYPING -->
@ -185,6 +189,7 @@
v-if="!currentInput || currentInput.length == 0 || showRecorder" v-if="!currentInput || currentInput.length == 0 || showRecorder"
> >
<v-btn <v-btn
v-if="canRecordAudio"
class="mic-button" class="mic-button"
ref="mic_button" ref="mic_button"
fab fab
@ -192,11 +197,23 @@
elevation="0" elevation="0"
v-blur v-blur
style="z-index: 10" style="z-index: 10"
:disabled="!canRecordAudio"
v-longTap:250="[showRecordingUI, startRecording]" v-longTap:250="[showRecordingUI, startRecording]"
> >
<v-icon :color="showRecorder ? 'white' : 'black'">mic</v-icon> <v-icon :color="showRecorder ? 'white' : 'black'">mic</v-icon>
</v-btn> </v-btn>
<v-btn
v-else
class="mic-button"
ref="mic_button"
fab
small
elevation="0"
v-blur
style="z-index: 10"
@click.stop="showNoRecordingAvailableDialog = true"
>
<v-icon :color="showRecorder ? 'white' : 'black'">mic</v-icon>
</v-btn>
</v-col> </v-col>
<v-col <v-col
@ -266,7 +283,11 @@
</v-container> </v-container>
<div v-if="currentImageInputPath"> <div v-if="currentImageInputPath">
<v-dialog v-model="currentImageInputPath" class="ma-0 pa-0" :width="$vuetify.breakpoint.smAndUp ? '50%' : '85%'"> <v-dialog
v-model="currentImageInputPath"
class="ma-0 pa-0"
:width="$vuetify.breakpoint.smAndUp ? '50%' : '85%'"
>
<v-card class="ma-0 pa-0"> <v-card class="ma-0 pa-0">
<v-card-text class="ma-0 pa-2"> <v-card-text class="ma-0 pa-2">
<v-img <v-img
@ -318,25 +339,23 @@
<v-divider></v-divider> <v-divider></v-divider>
<v-card-actions> <v-card-actions>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="primary" text @click="cancelSendAttachment" <v-btn color="primary" text @click="cancelSendAttachment">{{
>{{$t('menu.cancel')}}</v-btn $t("menu.cancel")
> }}</v-btn>
<v-btn <v-btn
color="primary" color="primary"
text text
@click="sendAttachment" @click="sendAttachment"
v-if="currentSendShowSendButton" v-if="currentSendShowSendButton"
:disabled="currentSendOperation != null" :disabled="currentSendOperation != null"
>{{$t('menu.send')}}</v-btn >{{ $t("menu.send") }}</v-btn
> >
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
</div> </div>
<MessageOperationsBottomSheet <MessageOperationsBottomSheet ref="messageOperationsSheet">
ref="messageOperationsSheet"
>
<MessageOperationsPicker <MessageOperationsPicker
v-on:close="showEmojiPicker = false" v-on:close="showEmojiPicker = false"
v-if="selectedEvent" v-if="selectedEvent"
@ -379,6 +398,29 @@
</v-container> </v-container>
<RoomInfoBottomSheet ref="roomInfoSheet" /> <RoomInfoBottomSheet ref="roomInfoSheet" />
<!-- Dialog for audio recording not supported! -->
<v-dialog
v-model="showNoRecordingAvailableDialog"
class="ma-0 pa-0"
width="80%"
>
<v-card>
<v-card-title>{{ $t("voice_recorder.not_supported_title") }}</v-card-title>
<v-card-text>{{ $t("voice_recorder.not_supported_text") }}
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="primary"
text
@click="showNoRecordingAvailableDialog = false"
>{{ $t("menu.ok") }}</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</div> </div>
</template> </template>
@ -523,6 +565,7 @@ export default {
selectedEvent: null, selectedEvent: null,
editedEvent: null, editedEvent: null,
replyToEvent: null, replyToEvent: null,
showNoRecordingAvailableDialog: false,
showContextMenu: false, showContextMenu: false,
showContextMenuAnchor: null, showContextMenuAnchor: null,
showAvatarMenu: false, showAvatarMenu: false,
@ -628,9 +671,11 @@ export default {
typingMembersString() { typingMembersString() {
const count = this.typingMembers.length; const count = this.typingMembers.length;
if (count > 1) { if (count > 1) {
return this.$t('message.users_are_typing',{count: count}); return this.$t("message.users_are_typing", { count: count });
} else if (count > 0) { } else if (count > 0) {
return this.$t('message.user_is_typing',{user: this.typingMembers[0].name}); return this.$t("message.user_is_typing", {
user: this.typingMembers[0].name,
});
} else { } else {
return ""; return "";
} }
@ -1002,7 +1047,7 @@ export default {
return RoomJoinRules; return RoomJoinRules;
case "m.room.power_levels": case "m.room.power_levels":
return RoomPowerLevelsChanged; return RoomPowerLevelsChanged;
case "m.room.encryption": case "m.room.encryption":
return RoomEncrypted; return RoomEncrypted;
@ -1193,10 +1238,14 @@ export default {
onUploadProgress(p) { onUploadProgress(p) {
if (p.total) { if (p.total) {
this.currentSendProgress = this.currentSendProgress = this.$t(
this.$t('message.upload_progress_with_total',{count: (p.loaded || 0), total: p.total}); "message.upload_progress_with_total",
{ count: p.loaded || 0, total: p.total }
);
} else { } else {
this.currentSendProgress = this.$t('message.upload_progress',{count: (p.loaded || 0)}); this.currentSendProgress = this.$t("message.upload_progress", {
count: p.loaded || 0,
});
} }
}, },
@ -1382,7 +1431,8 @@ export default {
const link = document.createElement("a"); const link = document.createElement("a");
link.href = url; link.href = url;
link.target = "_blank"; link.target = "_blank";
link.download = event.getContent().body || this.$t('fallbacks.download_name'); link.download =
event.getContent().body || this.$t("fallbacks.download_name");
link.click(); link.click();
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
}) })