From a5865825dae408509b4129de95c2d8a4a847fbbf Mon Sep 17 00:00:00 2001
From: Lim Chee Aun
Date: Wed, 30 Aug 2023 17:42:33 +0800
Subject: [PATCH 09/12] Init states again after login to new account
---
src/app.jsx | 3 ++-
src/utils/states.js | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/app.jsx b/src/app.jsx
index 0f491e94..16efbe2d 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -58,7 +58,7 @@ import {
import { getAccessToken } from './utils/auth';
import openCompose from './utils/open-compose';
import showToast from './utils/show-toast';
-import states, { getStatus, saveStatus } from './utils/states';
+import states, { initStates, saveStatus } from './utils/states';
import store from './utils/store';
import { getCurrentAccount } from './utils/store-utils';
import useInterval from './utils/useInterval';
@@ -130,6 +130,7 @@ function App() {
initInstance(masto, instanceURL),
initAccount(masto, instanceURL, accessToken),
]);
+ initStates();
initPreferences(masto);
setIsLoggedIn(true);
diff --git a/src/utils/states.js b/src/utils/states.js
index 6b8e281a..dde99563 100644
--- a/src/utils/states.js
+++ b/src/utils/states.js
@@ -60,6 +60,30 @@ const states = proxy({
export default states;
+export function initStates() {
+ // init all account based states
+ // all keys that uses store.account.get() should be initialized here
+ states.notificationsLast = store.account.get('notificationsLast') || null;
+ states.shortcuts = store.account.get('shortcuts') ?? [];
+ states.settings.autoRefresh =
+ store.account.get('settings-autoRefresh') ?? false;
+ states.settings.shortcutsViewMode =
+ store.account.get('settings-shortcutsViewMode') ?? null;
+ states.settings.shortcutsColumnsMode =
+ store.account.get('settings-shortcutsColumnsMode') ?? false;
+ states.settings.boostsCarousel =
+ store.account.get('settings-boostsCarousel') ?? true;
+ states.settings.contentTranslation =
+ store.account.get('settings-contentTranslation') ?? true;
+ states.settings.contentTranslationTargetLanguage =
+ store.account.get('settings-contentTranslationTargetLanguage') || null;
+ states.settings.contentTranslationHideLanguages =
+ store.account.get('settings-contentTranslationHideLanguages') || [];
+ states.settings.contentTranslationAutoInline =
+ store.account.get('settings-contentTranslationAutoInline') ?? false;
+ states.settings.cloakMode = store.account.get('settings-cloakMode') ?? false;
+}
+
subscribeKey(states, 'notificationsLast', (v) => {
console.log('CHANGE', v);
store.account.set('notificationsLast', states.notificationsLast);
From 91419b3243703a0d36864d198ea77912bef9e799 Mon Sep 17 00:00:00 2001
From: Lim Chee Aun
Date: Wed, 30 Aug 2023 17:46:22 +0800
Subject: [PATCH 10/12] Enable relative path hosting
---
src/app.jsx | 2 +-
src/pages/accounts.jsx | 2 +-
src/utils/auth.js | 6 +++---
vite.config.js | 1 +
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/app.jsx b/src/app.jsx
index 16efbe2d..d31566c3 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -111,7 +111,7 @@ function App() {
if (code) {
console.log({ code });
// Clear the code from the URL
- window.history.replaceState({}, document.title, '/');
+ window.history.replaceState({}, document.title, location.pathname || '/');
const clientID = store.session.get('clientID');
const clientSecret = store.session.get('clientSecret');
diff --git a/src/pages/accounts.jsx b/src/pages/accounts.jsx
index c7910b5a..47d90b01 100644
--- a/src/pages/accounts.jsx
+++ b/src/pages/accounts.jsx
@@ -143,7 +143,7 @@ function Accounts({ onClose }) {
accounts.splice(i, 1);
store.local.setJSON('accounts', accounts);
// location.reload();
- location.href = '/';
+ location.href = location.pathname || '/';
}}
>
diff --git a/src/utils/auth.js b/src/utils/auth.js
index 36898f7a..600b0c0c 100644
--- a/src/utils/auth.js
+++ b/src/utils/auth.js
@@ -4,8 +4,8 @@ const { VITE_CLIENT_NAME: CLIENT_NAME, VITE_WEBSITE: WEBSITE } = import.meta
export async function registerApplication({ instanceURL }) {
const registrationParams = new URLSearchParams({
client_name: CLIENT_NAME,
- redirect_uris: location.origin,
scopes: 'read write follow',
+ redirect_uris: location.origin + location.pathname,
website: WEBSITE,
});
const registrationResponse = await fetch(
@@ -27,7 +27,7 @@ export async function getAuthorizationURL({ instanceURL, client_id }) {
const authorizationParams = new URLSearchParams({
client_id,
scope: 'read write follow',
- redirect_uri: location.origin,
+ redirect_uri: location.origin + location.pathname,
// redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
response_type: 'code',
});
@@ -44,7 +44,7 @@ export async function getAccessToken({
const params = new URLSearchParams({
client_id,
client_secret,
- redirect_uri: location.origin,
+ redirect_uri: location.origin + location.pathname,
grant_type: 'authorization_code',
code,
scope: 'read write follow',
diff --git a/vite.config.js b/vite.config.js
index 4eaec943..0cf8a335 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -25,6 +25,7 @@ const rollbarCode = fs.readFileSync(
// https://vitejs.dev/config/
export default defineConfig({
+ base: './',
mode: NODE_ENV,
define: {
__BUILD_TIME__: JSON.stringify(now),
From 5461b06130129df786d479bb7d7ba68b2a178cf5 Mon Sep 17 00:00:00 2001
From: Lim Chee Aun
Date: Wed, 30 Aug 2023 17:47:17 +0800
Subject: [PATCH 11/12] Safeguard deconstruct
---
src/app.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app.jsx b/src/app.jsx
index d31566c3..3cdbbdf0 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -390,7 +390,7 @@ function App() {
{
+ onClose={({ destination } = {}) => {
states.showAccount = false;
if (destination) {
states.showAccounts = false;
From 0b04e01d6043c1272a83cd396d94627e006263fe Mon Sep 17 00:00:00 2001
From: Lim Chee Aun
Date: Wed, 30 Aug 2023 20:16:34 +0800
Subject: [PATCH 12/12] Try out another style for 2nd-pass grouped
notifications
---
src/pages/notifications.css | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/pages/notifications.css b/src/pages/notifications.css
index 0ea71af5..9eb28951 100644
--- a/src/pages/notifications.css
+++ b/src/pages/notifications.css
@@ -153,20 +153,18 @@
left: 0;
font-size: 10px;
padding: 8px;
- color: var(--text-insignificant-color);
+ font-weight: bold;
}
.notification-group-statuses > li + li {
- margin-top: 8px;
+ margin-top: -1px;
}
-.notification .notification-group-statuses .status-link {
- max-height: 80px;
+.notification-group-statuses > li:not(:last-child) .status-link {
+ border-bottom-left-radius: 0;
+ border-bottom-right-radius: 0;
}
-.notification .notification-group-statuses .status-link .status {
- mask-image: linear-gradient(
- rgba(0, 0, 0, 1) 50px,
- rgba(0, 0, 0, 0.5) 70px,
- transparent 79px
- );
+.notification-group-statuses > li:not(:first-child) .status-link {
+ border-top-left-radius: 0;
+ border-top-right-radius: 0;
}
#mentions-option {