mirror of
https://iceshrimp.dev/blueb/Chuckya-fe-standalone.git
synced 2026-01-11 13:33:21 -08:00
add setting for single column mode
This commit is contained in:
parent
c1a1050835
commit
55805e341d
4 changed files with 31 additions and 14 deletions
|
|
@ -169,6 +169,15 @@ class LocalSettingsPage extends PureComponent {
|
|||
<FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' />
|
||||
<span className='hint'><FormattedMessage id='settings.wide_view_hint' defaultMessage='Stretches columns to better fill the available space.' /></span>
|
||||
</LocalSettingsPageItem>
|
||||
<LocalSettingsPageItem
|
||||
settings={settings}
|
||||
item={['single_column']}
|
||||
id='mastodon-settings--single_column'
|
||||
onChange={onChange}
|
||||
>
|
||||
<FormattedMessage id='settings.single_column' defaultMessage='Single column (Desktop mode only)' />
|
||||
<span className='hint'>Takes effect after a refresh.</span>
|
||||
</LocalSettingsPageItem>
|
||||
</section>
|
||||
</div>
|
||||
),
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ if (initialState) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @template {keyof InitialStateMeta} K
|
||||
* @param {K} prop
|
||||
|
|
@ -138,4 +139,7 @@ export const pollLimits = (initialState && initialState.poll_limits);
|
|||
export const defaultContentType = getMeta('default_content_type');
|
||||
export const useSystemEmojiFont = getMeta('system_emoji_font');
|
||||
|
||||
// Standalone-specific settings
|
||||
export const isSingleColumn = !forceSingleColumn && (initialState?.local_settings?.single_column ?? !hasMultiColumnPath);
|
||||
|
||||
export default initialState;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import { supportsPassiveEvents } from 'detect-passive-events';
|
||||
|
||||
import { forceSingleColumn, hasMultiColumnPath } from './initial_state';
|
||||
import { isSingleColumn } from './initial_state';
|
||||
|
||||
const LAYOUT_BREAKPOINT = 630;
|
||||
|
||||
export const isMobile = (width: number) => width <= LAYOUT_BREAKPOINT;
|
||||
|
||||
export const transientSingleColumn = !forceSingleColumn && !hasMultiColumnPath;
|
||||
export const transientSingleColumn = isSingleColumn;
|
||||
|
||||
export type LayoutType = 'mobile' | 'single-column' | 'multi-column';
|
||||
export const layoutFromWindow = (): LayoutType => {
|
||||
if (isMobile(window.innerWidth)) {
|
||||
return 'mobile';
|
||||
} else if (!forceSingleColumn && !transientSingleColumn) {
|
||||
} else if (!isSingleColumn) {
|
||||
return 'multi-column';
|
||||
} else {
|
||||
return 'single-column';
|
||||
|
|
|
|||
|
|
@ -11,35 +11,39 @@ async function loadState() {
|
|||
}
|
||||
|
||||
if (storedState && window.location.pathname !== '/prepare.html') {
|
||||
document.getElementById('initial-state').textContent = storedState;
|
||||
const isEl = document.getElementById('initial-state')
|
||||
if (isEl) {
|
||||
isEl.textContent = storedState;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const apiUrl = `https://${domain}/api`;
|
||||
const instance = await fetch(`${apiUrl}/v1/instance`).then(async p => await p.json());
|
||||
const options = {headers: {Authorization: `Bearer ${access_token}`}};
|
||||
const options = { headers: { Authorization: `Bearer ${access_token}` } };
|
||||
const credentials = await fetch(`${apiUrl}/v1/accounts/verify_credentials`, options).then(async p => await p.json());
|
||||
const state = {
|
||||
"accounts": {
|
||||
"plc":{
|
||||
"accepts_direct_messages_from":"everybody",
|
||||
"plc": {
|
||||
"accepts_direct_messages_from": "everybody",
|
||||
"acct": credentials.acct,
|
||||
"avatar": credentials.avatar,
|
||||
"avatar_static": credentials.avatar_static,
|
||||
"bot": credentials.bot,
|
||||
"created_at": credentials.created_at,
|
||||
"display_name": credentials.display_name,
|
||||
"emojis":[],
|
||||
"fields":[],
|
||||
"follow_requests_count":0,
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"follow_requests_count": 0,
|
||||
"followers_count": credentials.followers_count,
|
||||
"following_count": credentials.following_count,
|
||||
"fqn":`${credentials.acct}@${domain}`,
|
||||
"fqn": `${credentials.acct}@${domain}`,
|
||||
"header": credentials.header,
|
||||
"header_static": credentials.header_static,
|
||||
"id": credentials.id,
|
||||
"last_status_at": credentials.created_at,
|
||||
"locked": credentials.locked,
|
||||
"note":"",
|
||||
"note": "",
|
||||
"source": credentials.source,
|
||||
"statuses_count": credentials.statuses_count,
|
||||
"url": credentials.url,
|
||||
|
|
@ -98,7 +102,7 @@ async function loadState() {
|
|||
"en": 1
|
||||
}
|
||||
},
|
||||
"languages":[
|
||||
"languages": [
|
||||
[
|
||||
"aa",
|
||||
"Afar",
|
||||
|
|
@ -1091,4 +1095,4 @@ async function loadState() {
|
|||
if (window.location.pathname !== '/prepare.html') document.getElementById('initial-state').textContent = json;
|
||||
localStorage.setItem("initial_state", json);
|
||||
if (window.location.pathname === '/prepare.html') window.location.href = '/';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue