Merge remote-tracking branch 'origin/develop' into fixes-roundup5
This commit is contained in:
commit
7b9d192d51
28 changed files with 1392 additions and 629 deletions
|
|
@ -1,3 +1,19 @@
|
|||
const checkCanvasExtractPermission = () => {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 1;
|
||||
canvas.height = 1;
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (!ctx) return false;
|
||||
|
||||
ctx.fillStyle = '#0f161e';
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
|
||||
const { data } = ctx.getImageData(0, 0, 1, 1);
|
||||
|
||||
return data.join(',') === '15,22,30,255';
|
||||
};
|
||||
|
||||
const createFaviconService = () => {
|
||||
const favicons = []
|
||||
const faviconWidth = 128
|
||||
|
|
@ -5,6 +21,8 @@ const createFaviconService = () => {
|
|||
const badgeRadius = 32
|
||||
|
||||
const initFaviconService = () => {
|
||||
if (!checkCanvasExtractPermission()) return;
|
||||
|
||||
const nodes = document.querySelectorAll('link[rel="icon"]')
|
||||
nodes.forEach(favicon => {
|
||||
if (favicon) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,20 @@
|
|||
import { reduce } from 'lodash'
|
||||
import { StatusCodeError } from 'src/services/errors/errors.js'
|
||||
|
||||
const REDIRECT_URI = `${window.location.origin}/oauth-callback`
|
||||
|
||||
export const getOrCreateApp = ({ clientId, clientSecret, instance, commit }) => {
|
||||
if (clientId && clientSecret) {
|
||||
return Promise.resolve({ clientId, clientSecret })
|
||||
export const getJsonOrError = async (response) => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
.catch((error) => {
|
||||
throw new StatusCodeError(response.status, error, {}, response)
|
||||
})
|
||||
} else {
|
||||
throw new StatusCodeError(response.status, await response.text(), {}, response)
|
||||
}
|
||||
}
|
||||
|
||||
export const createApp = (instance) => {
|
||||
const url = `${instance}/api/v1/apps`
|
||||
const form = new window.FormData()
|
||||
|
||||
|
|
@ -19,9 +27,16 @@ export const getOrCreateApp = ({ clientId, clientSecret, instance, commit }) =>
|
|||
method: 'POST',
|
||||
body: form
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then(getJsonOrError)
|
||||
.then((app) => ({ clientId: app.client_id, clientSecret: app.client_secret }))
|
||||
.then((app) => commit('setClientData', app) || app)
|
||||
}
|
||||
|
||||
export const verifyAppToken = ({ instance, appToken }) => {
|
||||
return window.fetch(`${instance}/api/v1/apps/verify_credentials`, {
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Bearer ${appToken}` }
|
||||
})
|
||||
.then(getJsonOrError)
|
||||
}
|
||||
|
||||
const login = ({ instance, clientId }) => {
|
||||
|
|
@ -92,7 +107,7 @@ export const getClientToken = ({ clientId, clientSecret, instance }) => {
|
|||
return window.fetch(url, {
|
||||
method: 'POST',
|
||||
body: form
|
||||
}).then((data) => data.json())
|
||||
}).then(getJsonOrError)
|
||||
}
|
||||
const verifyOTPCode = ({ app, instance, mfaToken, code }) => {
|
||||
const url = `${instance}/oauth/mfa/challenge`
|
||||
|
|
@ -144,7 +159,6 @@ const oauth = {
|
|||
login,
|
||||
getToken,
|
||||
getTokenWithCredentials,
|
||||
getOrCreateApp,
|
||||
verifyOTPCode,
|
||||
verifyRecoveryCode,
|
||||
revokeToken
|
||||
|
|
|
|||
|
|
@ -124,16 +124,33 @@ export const applyTheme = (
|
|||
const lazyStyles = createStyleSheet(LAZY_STYLE_ID)
|
||||
|
||||
const insertRule = (styles, rule) => {
|
||||
if (rule.indexOf('webkit') >= 0) {
|
||||
try {
|
||||
// Try to use modern syntax first
|
||||
try {
|
||||
styles.sheet.insertRule(rule, 'index-max')
|
||||
styles.rules.push(rule)
|
||||
} catch (e) {
|
||||
console.warn('Can\'t insert rule due to lack of support', e)
|
||||
} catch {
|
||||
// Fallback for older browsers that don't support 'index-max'
|
||||
styles.sheet.insertRule(rule, styles.sheet.cssRules.length)
|
||||
styles.rules.push(rule)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Can\'t insert rule due to lack of support', e, rule)
|
||||
|
||||
// Try to sanitize the rule for better compatibility
|
||||
try {
|
||||
// Remove any potentially problematic CSS features
|
||||
let sanitizedRule = rule
|
||||
.replace(/backdrop-filter:[^;]+;/g, '') // Remove backdrop-filter
|
||||
.replace(/var\(--shadowFilter\)[^;]*;/g, '') // Remove shadowFilter references
|
||||
|
||||
if (sanitizedRule !== rule) {
|
||||
styles.sheet.insertRule(sanitizedRule, styles.sheet.cssRules.length)
|
||||
styles.rules.push(sanitizedRule)
|
||||
}
|
||||
} catch (e2) {
|
||||
console.error('Failed to insert even sanitized rule', e2)
|
||||
}
|
||||
} else {
|
||||
styles.sheet.insertRule(rule, 'index-max')
|
||||
styles.rules.push(rule)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +187,7 @@ const extractStyleConfig = ({
|
|||
sidebarColumnWidth,
|
||||
contentColumnWidth,
|
||||
notifsColumnWidth,
|
||||
themeEditorMinWidth,
|
||||
emojiReactionsScale,
|
||||
emojiSize,
|
||||
navbarSize,
|
||||
|
|
@ -181,6 +199,7 @@ const extractStyleConfig = ({
|
|||
sidebarColumnWidth,
|
||||
contentColumnWidth,
|
||||
notifsColumnWidth,
|
||||
themeEditorMinWidth: parseInt(themeEditorMinWidth) === 0 ? 'fit-content' : themeEditorMinWidth,
|
||||
emojiReactionsScale,
|
||||
emojiSize,
|
||||
navbarSize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue