1
0
Fork 0
mirror of https://github.com/mat-1/variance.git synced 2025-08-02 15:26:04 +00:00

default sendOnEnter based on whether device is touchscreen

closes #2
This commit is contained in:
mat 2023-10-14 13:00:39 -05:00
parent cecc224643
commit d1a84e519e
3 changed files with 11 additions and 8 deletions

View file

@ -558,7 +558,7 @@ function YoutubeEmbed({ link }) {
<div className="embed-container">
<IframePlayer
link={link}
sitename="Youtube"
sitename="YouTube"
title={urlPreviewInfo['og:title']}
thumbnail={mx.mxcUrlToHttp(urlPreviewInfo['og:image'])}
>

View file

@ -144,7 +144,7 @@ function AppearanceSection() {
content={<Text variant="b3">Show additional info about URLs.</Text>}
/>
<SettingTile
title="Show Youtube embed player"
title="Show YouTube embed player"
options={
<Toggle
isActive={settings.showYoutubeEmbedPlayer}

View file

@ -17,6 +17,8 @@ function setSettings(key, value) {
}
class Settings extends EventEmitter {
isTouchScreenDevice: boolean;
themes: string[];
themeIndex: number;
@ -49,11 +51,11 @@ class Settings extends EventEmitter {
clearUrls: boolean;
isTouchScreenDevice: boolean;
constructor() {
super();
this.isTouchScreenDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
this.themes = ['', 'silver-theme', 'dark-theme', 'butter-theme', 'ayu-theme'];
this.themeIndex = this.getThemeIndex();
@ -71,8 +73,6 @@ class Settings extends EventEmitter {
this.showUrlPreview = this.getShowUrlPreview();
this.sendReadReceipts = this.getSendReadReceipts();
this.clearUrls = this.getClearUrls();
this.isTouchScreenDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
}
getThemeIndex() {
@ -160,8 +160,11 @@ class Settings extends EventEmitter {
if (typeof this.sendMessageOnEnter === 'boolean') return this.sendMessageOnEnter;
const settings = getSettings();
if (settings === null) return true;
if (typeof settings.sendMessageOnEnter === 'undefined') return true;
const defaultSendOnEnter = !this.isTouchScreenDevice;
if (settings === null) return defaultSendOnEnter;
if (typeof settings.sendMessageOnEnter === 'undefined') return defaultSendOnEnter;
return settings.sendMessageOnEnter;
}