diff --git a/src/app.jsx b/src/app.jsx
index 91d0435b0..3dafd3807 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -83,6 +83,7 @@ function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [uiState, setUIState] = useState('loading');
const instanceURL = store.local.get('instanceURL');
+ const myCurrentInstance = api().instance;
const { instance } = api();
const formattedShortcuts = [
{
@@ -282,7 +283,7 @@ function App() {
} />
} />
- } />
+ } />
{isLoggedIn && } />}
} />
{/* } /> */}
diff --git a/src/pages/status.jsx b/src/pages/status.jsx
index e8c397181..403957d7f 100644
--- a/src/pages/status.jsx
+++ b/src/pages/status.jsx
@@ -248,30 +248,12 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
const hasStatus = !!snapStates.statuses[sKey];
let heroStatus = snapStates.statuses[sKey];
- if (hasStatus && !reloadHero) {
- console.debug('Hero status is cached');
- } else {
- try {
- heroStatus = await heroFetch();
- saveStatus(heroStatus, instance);
- // Give time for context to appear
- await new Promise((resolve) => {
- setTimeout(resolve, 100);
- });
- } catch (e) {
- console.error(e);
- setUIState('error');
- return;
- }
- }
-
// Automatically switch to users instance to allow interacting with a status
-
const canAutoLoadThisInstance = () => {
return myCurrentInstance != 'ditto.pub' && myCurrentInstance != 'skybridge.fly.dev' && heroStatus.account.acct.indexOf("mostr.pub") === -1 && heroStatus.account.acct.indexOf("threads.net") === -1;
}
-
- if (canAutoLoadThisInstance()) {
+
+ const autoLoadThisInstance = () => {
setUIState('loading');
(async () => {
try {
@@ -298,6 +280,29 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
}
})();
}
+ if (hasStatus && !reloadHero) {
+ if (canAutoLoadThisInstance()) {
+ autoLoadThisInstance();
+ }
+ console.debug('Hero status is cached');
+ } else {
+ try {
+ heroStatus = await heroFetch();
+ saveStatus(heroStatus, instance);
+
+ if (canAutoLoadThisInstance()) {
+ autoLoadThisInstance();
+ }
+ // Give time for context to appear
+ await new Promise((resolve) => {
+ setTimeout(resolve, 100);
+ });
+ } catch (e) {
+ console.error(e);
+ setUIState('error');
+ return;
+ }
+ }
try {
const context = await contextFetch;
diff --git a/src/pages/trending.jsx b/src/pages/trending.jsx
index 9ac7acc20..e2130b73f 100644
--- a/src/pages/trending.jsx
+++ b/src/pages/trending.jsx
@@ -34,12 +34,13 @@ function Trending({ columnMode, ...props }) {
const snapStates = useSnapshot(states);
const params = columnMode ? {} : useParams();
const [uiState, setUIState] = useState('default');
+ const myCurrentInstance = api().instance;
const { masto, instance } = api({
instance: params.instance === 'ditto.pub' ? 'mastodon.social' : params.instance === 'skybridge.fly.dev' ? 'mastodon.social' : props?.instance || params.instance,
});
const title = `Trending`;
- useTitle(title, `/:instance?/trending`);
+ useTitle(title, `/:myCurrentInstance?/trending`);
// const navigate = useNavigate();
const latestItem = useRef();