Merge pull request #37 from cheeaun/main

Update from main
This commit is contained in:
Chee Aun 2022-12-27 22:07:51 +08:00 committed by GitHub
commit 9e9f7a6ea1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 20 deletions

1
.env.production Normal file
View file

@ -0,0 +1 @@
VITE_APP_ENV=production

View file

@ -6,7 +6,7 @@
name="viewport"
content="width=device-width, initial-scale=1, viewport-fit=cover"
/>
<title>Phanpy</title>
<title><{ VITE_CLIENT_NAME }></title>
<meta
name="description"
content="Minimalistic opinionated Mastodon web client"
@ -14,10 +14,10 @@
<meta name="color-scheme" content="dark light" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-title" content="Phanpy" />
<meta name="apple-mobile-web-app-title" content="<{ VITE_CLIENT_NAME }>" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<link rel="canonical" href="https://phanpy.social" />
<link rel="canonical" href="<{ VITE_WEBSITE }>" />
<meta
name="theme-color"
content="#fff"
@ -28,13 +28,16 @@
content="#242526"
media="(prefers-color-scheme: dark)"
/>
<script>
<script vite-if="import.meta.env.VITE_APP_ENV === production">
var isDev = /dev\./.test(window.location.hostname);
var _rollbarConfig = {
accessToken: 'ec3e07829d324a29abf6c83472a9740d',
captureUncaught: true,
captureUnhandledRejections: true,
enabled: isDev,
hostSafeList: ['dev.phanpy.social', 'phanpy.social'],
payload: {
environment: 'production',
environment: isDev ? 'development' : 'production',
},
};
// Rollbar Snippet

34
package-lock.json generated
View file

@ -22,7 +22,7 @@
"string-length": "~5.0.1",
"toastify-js": "~1.12.0",
"use-resize-observer": "~9.1.0",
"valtio": "~1.7.6"
"valtio": "~1.8.0"
},
"devDependencies": {
"@preact/preset-vite": "~2.5.0",
@ -32,6 +32,7 @@
"postcss-dark-theme-class": "~0.7.3",
"twitter-text": "~3.1.0",
"vite": "~4.0.3",
"vite-plugin-html-env": "~1.2.7",
"vite-plugin-pwa": "~0.14.0",
"workbox-cacheable-response": "~6.5.4",
"workbox-expiration": "~6.5.4",
@ -5318,9 +5319,9 @@
}
},
"node_modules/valtio": {
"version": "1.7.6",
"resolved": "https://registry.npmjs.org/valtio/-/valtio-1.7.6.tgz",
"integrity": "sha512-zsGrCCYOIpy8egQxftduFyJusF/BMu3CganhHKUOE/I6t6V6yA1MDfZZkrYoWYCGkC3rSBYcIHEEsoYQM9lV2w==",
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/valtio/-/valtio-1.8.0.tgz",
"integrity": "sha512-lNw7wM0Qb9iBzXMju+XCn+UiIlf5uCe5pcI8XRqcvxEZ/mnRXyKXoOodPDKB8cIAVekA3Q3zWA7rboCdS4ea7g==",
"dependencies": {
"proxy-compare": "2.3.0",
"use-sync-external-store": "1.2.0"
@ -5406,6 +5407,18 @@
}
}
},
"node_modules/vite-plugin-html-env": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/vite-plugin-html-env/-/vite-plugin-html-env-1.2.7.tgz",
"integrity": "sha512-vdTnKtuBeB8Zp93DCbN0Qjf4odW2msVRq45r7lGKA6nwQGJFj6YemU54u3xPPkvDeZhG8DEEU64xbLwzVEBilQ==",
"dev": true,
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"vite": "*"
}
},
"node_modules/vite-plugin-pwa": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.14.0.tgz",
@ -9576,9 +9589,9 @@
"requires": {}
},
"valtio": {
"version": "1.7.6",
"resolved": "https://registry.npmjs.org/valtio/-/valtio-1.7.6.tgz",
"integrity": "sha512-zsGrCCYOIpy8egQxftduFyJusF/BMu3CganhHKUOE/I6t6V6yA1MDfZZkrYoWYCGkC3rSBYcIHEEsoYQM9lV2w==",
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/valtio/-/valtio-1.8.0.tgz",
"integrity": "sha512-lNw7wM0Qb9iBzXMju+XCn+UiIlf5uCe5pcI8XRqcvxEZ/mnRXyKXoOodPDKB8cIAVekA3Q3zWA7rboCdS4ea7g==",
"requires": {
"proxy-compare": "2.3.0",
"use-sync-external-store": "1.2.0"
@ -9597,6 +9610,13 @@
"rollup": "^3.7.0"
}
},
"vite-plugin-html-env": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/vite-plugin-html-env/-/vite-plugin-html-env-1.2.7.tgz",
"integrity": "sha512-vdTnKtuBeB8Zp93DCbN0Qjf4odW2msVRq45r7lGKA6nwQGJFj6YemU54u3xPPkvDeZhG8DEEU64xbLwzVEBilQ==",
"dev": true,
"requires": {}
},
"vite-plugin-pwa": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.14.0.tgz",

View file

@ -24,7 +24,7 @@
"string-length": "~5.0.1",
"toastify-js": "~1.12.0",
"use-resize-observer": "~9.1.0",
"valtio": "~1.7.6"
"valtio": "~1.8.0"
},
"devDependencies": {
"@preact/preset-vite": "~2.5.0",
@ -34,6 +34,7 @@
"postcss-dark-theme-class": "~0.7.3",
"twitter-text": "~3.1.0",
"vite": "~4.0.3",
"vite-plugin-html-env": "~1.2.7",
"vite-plugin-pwa": "~0.14.0",
"workbox-cacheable-response": "~6.5.4",
"workbox-expiration": "~6.5.4",

View file

@ -51,6 +51,8 @@ const menu = document.createElement('ul');
menu.role = 'listbox';
menu.className = 'text-expander-menu';
const DEFAULT_LANG = 'en';
function Compose({
onClose,
replyToStatus,
@ -104,7 +106,7 @@ function Compose({
const [visibility, setVisibility] = useState('public');
const [sensitive, setSensitive] = useState(false);
const [language, setLanguage] = useState(
store.session.get('currentLanguage') || 'en',
store.session.get('currentLanguage') || DEFAULT_LANG,
);
const [mediaAttachments, setMediaAttachments] = useState([]);
const [poll, setPoll] = useState(null);
@ -154,7 +156,7 @@ function Compose({
}
focusTextarea();
setVisibility(visibility);
setLanguage(language);
setLanguage(language || DEFAULT_LANG);
setSensitive(sensitive);
}
if (draftStatus) {
@ -177,7 +179,7 @@ function Compose({
focusTextarea();
spoilerTextRef.current.value = spoilerText;
setVisibility(visibility);
setLanguage(language);
setLanguage(language || DEFAULT_LANG);
setSensitive(sensitive);
setPoll(composablePoll);
setMediaAttachments(mediaAttachments);
@ -203,7 +205,7 @@ function Compose({
focusTextarea();
spoilerTextRef.current.value = spoilerText;
setVisibility(visibility);
setLanguage(language);
setLanguage(language || DEFAULT_LANG);
setSensitive(sensitive);
setPoll(composablePoll);
setMediaAttachments(mediaAttachments);
@ -955,14 +957,14 @@ function Compose({
)}
<label class="toolbar-button">
<span class="icon-text">
{supportedLanguagesMap[language].native}
{supportedLanguagesMap[language]?.native}
</span>
<select
name="language"
value={language}
onChange={(e) => {
const { value } = e.target;
setLanguage(value);
setLanguage(value || DEFAULT_LANG);
store.session.set('language', value);
}}
disabled={uiState === 'loading'}

View file

@ -83,11 +83,12 @@ function StatusPage({ id }) {
states.statuses.set(id, heroStatus);
} catch (e) {
// Silent fail if status is cached
console.error(e);
if (!hasStatus) {
setUIState('error');
alert('Error fetching status');
return;
}
return;
}
try {

View file

@ -2,6 +2,7 @@ import preact from '@preact/preset-vite';
import { execSync } from 'child_process';
import { resolve } from 'path';
import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite';
import VitePluginHtmlEnv from 'vite-plugin-html-env';
import { VitePWA } from 'vite-plugin-pwa';
const { VITE_CLIENT_NAME: CLIENT_NAME, NODE_ENV } = loadEnv(
@ -21,6 +22,7 @@ export default defineConfig({
plugins: [
preact(),
splitVendorChunkPlugin(),
VitePluginHtmlEnv(),
VitePWA({
manifest: {
name: CLIENT_NAME,