Skip to content

Commit

Permalink
Merge branch 'main' into hailey/fabric-migration-pt1
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
  • Loading branch information
haileyok committed Mar 6, 2024
2 parents b36af05 + 2d9a5db commit eb902fa
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 145 deletions.
3 changes: 2 additions & 1 deletion app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ module.exports = function (config) {
'expo-notifications',
{
icon: './assets/icon-android-notification.png',
color: '#ffffff',
color: '#1185fe',
},
],
'./plugins/withAndroidManifestPlugin.js',
'./plugins/withAndroidManifestFCMIconPlugin.js',
'./plugins/withAndroidStylesWindowBackgroundPlugin.js',
'./plugins/shareExtension/withShareExtensions.js',
].filter(Boolean),
Expand Down
70 changes: 0 additions & 70 deletions bskyweb/cmd/bskyweb/mailmodo.go

This file was deleted.

12 changes: 0 additions & 12 deletions bskyweb/cmd/bskyweb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ func run(args []string) {
// retain old PDS env var for easy transition
EnvVars: []string{"ATP_APPVIEW_HOST", "ATP_PDS_HOST"},
},
&cli.StringFlag{
Name: "mailmodo-api-key",
Usage: "Mailmodo API key",
Required: false,
EnvVars: []string{"MAILMODO_API_KEY"},
},
&cli.StringFlag{
Name: "mailmodo-list-name",
Usage: "Mailmodo contact list to add email addresses to",
Required: false,
EnvVars: []string{"MAILMODO_LIST_NAME"},
},
&cli.StringFlag{
Name: "http-address",
Usage: "Specify the local IP/port to bind to",
Expand Down
55 changes: 5 additions & 50 deletions bskyweb/cmd/bskyweb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package main

import (
"context"
"encoding/json"
"errors"
"fmt"
"io/fs"
"io/ioutil"
"net/http"
"os"
"os/signal"
Expand All @@ -29,25 +27,19 @@ import (
)

type Server struct {
echo *echo.Echo
httpd *http.Server
mailmodo *Mailmodo
xrpcc *xrpc.Client
echo *echo.Echo
httpd *http.Server
xrpcc *xrpc.Client
}

func serve(cctx *cli.Context) error {
debug := cctx.Bool("debug")
httpAddress := cctx.String("http-address")
appviewHost := cctx.String("appview-host")
mailmodoAPIKey := cctx.String("mailmodo-api-key")
mailmodoListName := cctx.String("mailmodo-list-name")

// Echo
e := echo.New()

// Mailmodo client.
mailmodo := NewMailmodo(mailmodoAPIKey, mailmodoListName)

// create a new session (no auth)
xrpcc := &xrpc.Client{
Client: cliutil.NewHttpClient(),
Expand Down Expand Up @@ -77,9 +69,8 @@ func serve(cctx *cli.Context) error {
// server
//
server := &Server{
echo: e,
mailmodo: mailmodo,
xrpcc: xrpcc,
echo: e,
xrpcc: xrpcc,
}

// Create the HTTP server.
Expand Down Expand Up @@ -221,9 +212,6 @@ func serve(cctx *cli.Context) error {
e.GET("/profile/:handleOrDID/post/:rkey/liked-by", server.WebGeneric)
e.GET("/profile/:handleOrDID/post/:rkey/reposted-by", server.WebGeneric)

// Mailmodo
e.POST("/api/waitlist", server.apiWaitlist)

// Start the server.
log.Infof("starting server address=%s", httpAddress)
go func() {
Expand Down Expand Up @@ -398,36 +386,3 @@ func (srv *Server) WebProfile(c echo.Context) error {
data["requestHost"] = req.Host
return c.Render(http.StatusOK, "profile.html", data)
}

func (srv *Server) apiWaitlist(c echo.Context) error {
type jsonError struct {
Error string `json:"error"`
}

// Read the API request.
type apiRequest struct {
Email string `json:"email"`
}

bodyReader := http.MaxBytesReader(c.Response(), c.Request().Body, 16*1024)
payload, err := ioutil.ReadAll(bodyReader)
if err != nil {
return err
}
var req apiRequest
if err := json.Unmarshal(payload, &req); err != nil {
return c.JSON(http.StatusBadRequest, jsonError{Error: "Invalid API request"})
}

if req.Email == "" {
return c.JSON(http.StatusBadRequest, jsonError{Error: "Please enter a valid email address."})
}

if err := srv.mailmodo.AddToList(c.Request().Context(), req.Email); err != nil {
log.Errorf("adding email to waitlist failed: %s", err)
return c.JSON(http.StatusBadRequest, jsonError{
Error: "Storing email in waitlist failed. Please enter a valid email address.",
})
}
return c.JSON(http.StatusOK, map[string]bool{"success": true})
}
37 changes: 37 additions & 0 deletions plugins/withAndroidManifestFCMIconPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const {withAndroidManifest} = require('expo/config-plugins')

module.exports = function withAndroidManifestFCMIconPlugin(appConfig) {
return withAndroidManifest(appConfig, function (decoratedAppConfig) {
try {
function addOrModifyMetaData(metaData, name, resource) {
const elem = metaData.find(elem => elem.$['android:name'] === name)
if (elem === undefined) {
metaData.push({
$: {
'android:name': name,
'android:resource': resource,
},
})
} else {
elem.$['android:resource'] = resource
}
}
const androidManifest = decoratedAppConfig.modResults.manifest
const metaData = androidManifest.application[0]['meta-data']
addOrModifyMetaData(
metaData,
'com.google.firebase.messaging.default_notification_color',
'@color/notification_icon_color',
)
addOrModifyMetaData(
metaData,
'com.google.firebase.messaging.default_notification_icon',
'@drawable/notification_icon',
)
return decoratedAppConfig
} catch (e) {
console.error(`withAndroidManifestFCMIconPlugin failed`, e)
}
return decoratedAppConfig
})
}
13 changes: 8 additions & 5 deletions src/components/Lists.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {View} from 'react-native'
import {CenteredView} from 'view/com/util/Views'
import {Loader} from '#/components/Loader'
import {Trans} from '@lingui/macro'
import {cleanError} from 'lib/strings/errors'
Expand Down Expand Up @@ -143,7 +144,7 @@ export function ListMaybePlaceholder({
}) {
const navigation = useNavigation<NavigationProp>()
const t = useTheme()
const {gtMobile} = useBreakpoints()
const {gtMobile, gtTablet} = useBreakpoints()

const canGoBack = navigation.canGoBack()
const onGoBack = React.useCallback(() => {
Expand All @@ -165,14 +166,16 @@ export function ListMaybePlaceholder({
if (!isEmpty) return null

return (
<View
<CenteredView
style={[
a.flex_1,
a.align_center,
!gtMobile ? [a.justify_between, a.border_t] : a.gap_5xl,
!gtMobile ? a.justify_between : a.gap_5xl,
t.atoms.border_contrast_low,
{paddingTop: 175, paddingBottom: 110},
]}>
]}
sideBorders={gtMobile}
topBorder={!gtTablet}>
{isLoading ? (
<View style={[a.w_full, a.align_center, {top: 100}]}>
<Loader size="xl" />
Expand Down Expand Up @@ -241,6 +244,6 @@ export function ListMaybePlaceholder({
</View>
</>
)}
</View>
</CenteredView>
)
}
7 changes: 2 additions & 5 deletions src/screens/Hashtag.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import {ListRenderItemInfo, Pressable} from 'react-native'
import {atoms as a, useBreakpoints} from '#/alf'
import {useFocusEffect} from '@react-navigation/native'
import {useSetMinimalShellMode} from 'state/shell'
import {ViewHeader} from 'view/com/util/ViewHeader'
Expand All @@ -19,7 +18,6 @@ import {List} from 'view/com/util/List'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {sanitizeHandle} from 'lib/strings/handles'
import {CenteredView} from 'view/com/util/Views'
import {ArrowOutOfBox_Stroke2_Corner0_Rounded} from '#/components/icons/ArrowOutOfBox'
import {shareUrl} from 'lib/sharing'
import {HITSLOP_10} from 'lib/constants'
Expand All @@ -38,7 +36,6 @@ export default function HashtagScreen({
}: NativeStackScreenProps<CommonNavigatorParams, 'Hashtag'>) {
const {tag, author} = route.params
const setMinimalShellMode = useSetMinimalShellMode()
const {gtMobile} = useBreakpoints()
const {_} = useLingui()
const [isPTR, setIsPTR] = React.useState(false)

Expand Down Expand Up @@ -103,7 +100,7 @@ export default function HashtagScreen({
}, [isFetching, hasNextPage, error, fetchNextPage])

return (
<CenteredView style={a.flex_1} sideBorders={gtMobile}>
<>
<ViewHeader
title={headerTitle}
subtitle={author ? _(msg`From @${sanitizedAuthor}`) : undefined}
Expand Down Expand Up @@ -159,6 +156,6 @@ export default function HashtagScreen({
}
/>
)}
</CenteredView>
</>
)
}
4 changes: 3 additions & 1 deletion src/view/com/util/Views.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export function CenteredView({
style,
sideBorders,
...props
}: React.PropsWithChildren<ViewProps & {sideBorders?: boolean}>)
}: React.PropsWithChildren<
ViewProps & {sideBorders?: boolean; topBorder?: boolean}
>)
11 changes: 10 additions & 1 deletion src/view/com/util/Views.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ interface AddedProps {
export function CenteredView({
style,
sideBorders,
topBorder,
...props
}: React.PropsWithChildren<ViewProps & {sideBorders?: boolean}>) {
}: React.PropsWithChildren<
ViewProps & {sideBorders?: boolean; topBorder?: boolean}
>) {
const pal = usePalette('default')
const {isMobile} = useWebMediaQueries()
if (!isMobile) {
Expand All @@ -46,6 +49,12 @@ export function CenteredView({
})
style = addStyle(style, pal.border)
}
if (topBorder) {
style = addStyle(style, {
borderTopWidth: 1,
})
style = addStyle(style, pal.border)
}
return <View style={style} {...props} />
}

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18485,6 +18485,11 @@ react-native-date-picker@^4.4.0:
resolved "https://registry.yarnpkg.com/react-native-date-picker/-/react-native-date-picker-4.4.0.tgz#fe5b6eb8d85a4a30b2991ada5169a30ce5023ead"
integrity sha512-Axx3byihwwhKRLRVjPAr/UaEysapkRcKmjjM8/05UaVm4Q0xDn2RFUcRdy1QAahhRcjLjlVYhepxvU5bdgy7ZQ==

react-native-date-picker@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/react-native-date-picker/-/react-native-date-picker-4.4.0.tgz#fe5b6eb8d85a4a30b2991ada5169a30ce5023ead"
integrity sha512-Axx3byihwwhKRLRVjPAr/UaEysapkRcKmjjM8/05UaVm4Q0xDn2RFUcRdy1QAahhRcjLjlVYhepxvU5bdgy7ZQ==

react-native-dotenv@^3.3.1:
version "3.4.9"
resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-3.4.9.tgz#621c5b0c1d0c5c7f569bfe5a1d804bec7885c010"
Expand Down

0 comments on commit eb902fa

Please sign in to comment.