Added GoToSocial support

Fix #206
Fix https://github.com/superseriousbusiness/gotosocial/issues/825
This commit is contained in:
xmflsct 2023-01-08 20:07:20 +01:00
parent 43c0447418
commit a3b5a132c5
7 changed files with 30 additions and 70 deletions

View File

@ -1,4 +1,4 @@
# [tooot](https://tooot.app/) app for Mastodon
# [tooot](https://tooot.app/) app for Mastodon compatible platforms
[![GPL-3.0](https://img.shields.io/github/license/tooot-app/push)](LICENSE) ![GitHub issues](https://img.shields.io/github/issues/tooot-app/app) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/tooot-app/app?include_prereleases) [![Crowdin](https://badges.crowdin.net/tooot/localized.svg)](https://crowdin.tooot.app/project/tooot)

View File

@ -5,4 +5,5 @@ Enjoy toooting! This version includes following improvements and fixes:
- Allowing adding more context of reports
- Option to disable autoplay gif
- Hide boosts from users
- Followed hashtags are underlined
- Followed hashtags are underlined
- Support GoToSocial

View File

@ -5,4 +5,5 @@ toooting愉快此版本包括以下改进和修复
- 可添加举报细节
- 新增暂停自动播放gif动画选项
- 隐藏用户的转嘟
- 下划线高亮正在关注的话题标签
- 下划线高亮正在关注的话题标签
- 支持GoToSocial

View File

@ -338,6 +338,9 @@ declare namespace Mastodon {
contact: { email: string; account: Account }
rules: Rule[]
}
// Gotosocial
account_domain?: string
}
type Instance_V1 = {
// Base
@ -384,6 +387,9 @@ declare namespace Mastodon {
max_expiration: number
}
}
// Gotosocial
account_domain?: string
}
type Mention = {

View File

@ -8,7 +8,6 @@ import { TabMeStackNavigationProp } from '@utils/navigation/navigators'
import { queryClient } from '@utils/queryHooks'
import { redirectUri, useAppsMutation } from '@utils/queryHooks/apps'
import { useInstanceQuery } from '@utils/queryHooks/instance'
import { storage } from '@utils/storage'
import { StorageAccount } from '@utils/storage/account'
import {
generateAccountKey,
@ -26,7 +25,6 @@ import React, { RefObject, useCallback, useState } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { Alert, Image, KeyboardAvoidingView, Platform, TextInput, View } from 'react-native'
import { ScrollView } from 'react-native-gesture-handler'
import { MMKV } from 'react-native-mmkv'
import parse from 'url-parse'
import CustomText from '../Text'
@ -66,11 +64,13 @@ const ComponentInstance: React.FC<Props> = ({
}
})
const deprecateAuthFollow = featureCheck('deprecate_auth_follow')
const appsMutation = useAppsMutation({
retry: false,
onSuccess: async (data, variables) => {
const scopes = featureCheck('deprecate_auth_follow')
? ['read', 'write', 'push']
: ['read', 'write', 'follow', 'push']
const clientId = data.client_id
const clientSecret = data.client_secret
@ -79,9 +79,7 @@ const ComponentInstance: React.FC<Props> = ({
const request = new AuthSession.AuthRequest({
clientId,
clientSecret,
scopes: deprecateAuthFollow
? ['read', 'write', 'push']
: ['read', 'write', 'follow', 'push'],
scopes,
redirectUri
})
await request.makeAuthUrlAsync(discovery)
@ -93,10 +91,12 @@ const ComponentInstance: React.FC<Props> = ({
{
clientId,
clientSecret,
scopes: ['read', 'write', 'follow', 'push'],
scopes,
redirectUri,
code: promptResult.params.code,
extraParams: {
client_id: clientId,
client_secret: clientSecret,
grant_type: 'authorization_code',
...(request.codeVerifier && { code_verifier: request.codeVerifier })
}
@ -125,8 +125,13 @@ const ComponentInstance: React.FC<Props> = ({
'auth.domain': domain,
'auth.account.id': id,
'auth.account.acct': acct,
// @ts-ignore
'auth.account.domain': instanceQuery.data?.domain || instanceQuery.data?.uri,
'auth.account.domain':
(instanceQuery.data as Mastodon.Instance_V2)?.domain ||
instanceQuery.data?.account_domain ||
((instanceQuery.data as Mastodon.Instance_V1)?.uri
? parse((instanceQuery.data as Mastodon.Instance_V1).uri).hostname
: undefined) ||
(instanceQuery.data as Mastodon.Instance_V1)?.uri,
'auth.account.avatar_static': avatar_static,
version: instanceQuery.data?.version || '0',
preferences: undefined,

View File

@ -21,7 +21,8 @@ import { Pressable, View } from 'react-native'
import StatusContext from './Context'
const TimelinePoll: React.FC = () => {
const { queryKey, status, ownAccount, spoilerHidden, disableDetails } = useContext(StatusContext)
const { queryKey, status, ownAccount, spoilerHidden, disableDetails, highlighted } =
useContext(StatusContext)
if (!queryKey || !status || !status.poll) return null
const poll = status.poll
@ -92,7 +93,7 @@ const TimelinePoll: React.FC = () => {
/>
</View>
)
} else {
} else if (highlighted) {
return (
<View style={{ marginRight: StyleConstants.Spacing.S }}>
<Button
@ -166,7 +167,7 @@ const TimelinePoll: React.FC = () => {
borderTopRightRadius: 10,
borderBottomRightRadius: 10,
marginTop: StyleConstants.Spacing.XS,
marginBottom: StyleConstants.Spacing.S,
marginBottom: StyleConstants.Spacing.XS,
width: `${Math.round(
(option.votes_count / (poll.voters_count || poll.votes_count)) * 100
)}%`,

View File

@ -1,54 +0,0 @@
[
{
"feature": "account_follow_notify",
"version": 3.3
},
{
"feature": "notification_type_status",
"version": 3.3
},
{
"feature": "account_return_suspended",
"version": 3.3
},
{
"feature": "edit_post",
"version": 3.5
},
{
"feature": "deprecate_auth_follow",
"version": 3.5
},
{
"feature": "notification_type_update",
"version": 3.5
},
{
"feature": "notification_type_admin_signup",
"version": 3.5
},
{
"feature": "notification_types_positive_filter",
"version": 3.5
},
{
"feature": "trends_new_path",
"version": 3.5
},
{
"feature": "follow_tags",
"version": 4.0
},
{
"feature": "notification_type_admin_report",
"version": 4.0
},
{
"feature": "filter_server_side",
"version": 4.0
},
{
"feature": "instance_new_path",
"version": 4.0
}
]