diff --git a/Gemfile.lock b/Gemfile.lock
index 3e3c4d23..4a89e4dc 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -63,7 +63,7 @@ GEM
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
- cocoapods-downloader (1.6.2)
+ cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
diff --git a/ios/ShareExtension/Info.plist b/ios/ShareExtension/Info.plist
index 4d392fd1..d2042261 100644
--- a/ios/ShareExtension/Info.plist
+++ b/ios/ShareExtension/Info.plist
@@ -17,7 +17,7 @@
HostAppBundleIdentifier
com.xmflsct.app.tooot
HostAppURLScheme
- tooot://
+ tooot-share://
NSExtension
NSExtensionAttributes
diff --git a/ios/tooot/AppDelegate.m b/ios/tooot/AppDelegate.m
index 8a102a58..07d19ba1 100644
--- a/ios/tooot/AppDelegate.m
+++ b/ios/tooot/AppDelegate.m
@@ -6,6 +6,8 @@
#import
#import
+#import
+
#if defined(FB_SONARKIT_ENABLED) && __has_include()
#import
#import
@@ -81,6 +83,13 @@ static void InitializeFlipper(UIApplication *application) {
// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options {
+ NSString *urlString = url.absoluteString;
+
+ if ([urlString hasPrefix:@"tooot-share://"]) {
+ NSLog(@"Entered with the following string: %@s", urlString);
+ return [ShareMenuManager application:application openURL:url options:options];
+ }
+
return [RCTLinkingManager application:application openURL:url options:options];
}
diff --git a/ios/tooot/Info.plist b/ios/tooot/Info.plist
index b50b00ed..2f610bc1 100644
--- a/ios/tooot/Info.plist
+++ b/ios/tooot/Info.plist
@@ -31,6 +31,7 @@
com.xmflsct.app.tooot
CFBundleURLSchemes
+ tooot-share
tooot
diff --git a/package.json b/package.json
index 71165f76..3e8a9733 100644
--- a/package.json
+++ b/package.json
@@ -75,7 +75,6 @@
"react-native-fast-image": "8.5.11",
"react-native-feather": "1.1.2",
"react-native-flash-message": "0.2.1",
- "react-native-fs": "^2.19.0",
"react-native-gesture-handler": "2.4.1",
"react-native-htmlview": "0.16.0",
"react-native-pager-view": "5.4.11",
@@ -86,7 +85,6 @@
"react-native-svg": "12.3.0",
"react-native-swipe-list-view": "3.2.9",
"react-native-tab-view": "3.1.1",
- "react-native-uuid": "^2.0.1",
"react-query": "3.38.0",
"react-redux": "8.0.1",
"react-timeago": "6.2.1",
diff --git a/patches/@types+react-native-share-menu+5.0.2.patch b/patches/@types+react-native-share-menu+5.0.2.patch
index 09c4417f..997211e6 100644
--- a/patches/@types+react-native-share-menu+5.0.2.patch
+++ b/patches/@types+react-native-share-menu+5.0.2.patch
@@ -1,20 +1,19 @@
diff --git a/node_modules/@types/react-native-share-menu/index.d.ts b/node_modules/@types/react-native-share-menu/index.d.ts
-index f52822c..23d9f99 100755
+index f52822c..b1d3bdd 100755
--- a/node_modules/@types/react-native-share-menu/index.d.ts
+++ b/node_modules/@types/react-native-share-menu/index.d.ts
-@@ -6,9 +6,8 @@
+@@ -6,9 +6,7 @@
// Minimum TypeScript Version: 3.7
export interface ShareData {
- mimeType: string;
- data: string | string[];
- extraData?: object | undefined;
-+ data: {data: {mimeType: string; data: string}[]};
-+ extraData?: {share: {mimeType: string; data: string}[]} | undefined;
++ data: {mimeType: string; data: string}[];
}
export type ShareCallback = (share?: ShareData) => void;
-@@ -28,7 +27,7 @@ interface ShareMenuReactView {
+@@ -28,7 +26,7 @@ interface ShareMenuReactView {
dismissExtension(error?: string): void;
openApp(): void;
continueInApp(extraData?: object): void;
diff --git a/patches/react-native-share-menu+5.0.5.patch b/patches/react-native-share-menu+5.0.5.patch
index 66fe9eb9..96a4c59f 100644
--- a/patches/react-native-share-menu+5.0.5.patch
+++ b/patches/react-native-share-menu+5.0.5.patch
@@ -1,5 +1,5 @@
diff --git a/node_modules/react-native-share-menu/ios/Constants.swift b/node_modules/react-native-share-menu/ios/Constants.swift
-index 2811008..63761c3 100644
+index 2811008..08385b7 100644
--- a/node_modules/react-native-share-menu/ios/Constants.swift
+++ b/node_modules/react-native-share-menu/ios/Constants.swift
@@ -23,7 +23,7 @@ public let COULD_NOT_PARSE_IMG_ERROR = "Couldn't parse image"
@@ -12,7 +12,7 @@ index 2811008..63761c3 100644
// MARK: Keys
diff --git a/node_modules/react-native-share-menu/ios/Modules/ShareMenu.swift b/node_modules/react-native-share-menu/ios/Modules/ShareMenu.swift
-index 6c4922a..1277df2 100644
+index 6c4922a..74badda 100644
--- a/node_modules/react-native-share-menu/ios/Modules/ShareMenu.swift
+++ b/node_modules/react-native-share-menu/ios/Modules/ShareMenu.swift
@@ -9,7 +9,7 @@ class ShareMenu: RCTEventEmitter {
@@ -65,7 +65,7 @@ index 6c4922a..1277df2 100644
finalData[EXTRA_DATA_KEY] = extraData
}
diff --git a/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift b/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
-index 5d21773..d8a0847 100644
+index 5d21773..0c7eaa7 100644
--- a/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
+++ b/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
@@ -3,8 +3,9 @@
@@ -79,7 +79,16 @@ index 5d21773..d8a0847 100644
import MobileCoreServices
@objc(ShareMenuReactView)
-@@ -65,12 +66,12 @@ public class ShareMenuReactView: NSObject {
+@@ -17,8 +18,6 @@ public class ShareMenuReactView: NSObject {
+ }
+
+ public static func attachViewDelegate(_ delegate: ReactShareViewDelegate!) {
+- guard (ShareMenuReactView.viewDelegate == nil) else { return }
+-
+ ShareMenuReactView.viewDelegate = delegate
+ }
+
+@@ -65,12 +64,12 @@ public class ShareMenuReactView: NSObject {
let extensionContext = viewDelegate.loadExtensionContext()
@@ -95,7 +104,7 @@ index 5d21773..d8a0847 100644
}
@objc(data:reject:)
-@@ -82,91 +83,96 @@ public class ShareMenuReactView: NSObject {
+@@ -82,91 +81,96 @@ public class ShareMenuReactView: NSObject {
return
}
@@ -257,7 +266,7 @@ index 5d21773..d8a0847 100644
}
diff --git a/node_modules/react-native-share-menu/ios/ReactShareViewController.swift b/node_modules/react-native-share-menu/ios/ReactShareViewController.swift
-index 0189ef6..e620257 100644
+index 0189ef6..f42bce6 100644
--- a/node_modules/react-native-share-menu/ios/ReactShareViewController.swift
+++ b/node_modules/react-native-share-menu/ios/ReactShareViewController.swift
@@ -62,7 +62,7 @@ class ReactShareViewController: ShareViewController, RCTBridgeDelegate, ReactSha
@@ -270,9 +279,8 @@ index 0189ef6..e620257 100644
+ handlePost(items, extraData: extraData)
}
}
-\ No newline at end of file
diff --git a/node_modules/react-native-share-menu/ios/ReactShareViewDelegate.swift b/node_modules/react-native-share-menu/ios/ReactShareViewDelegate.swift
-index 0aa4c58..d2bc970 100644
+index 0aa4c58..ad0812c 100644
--- a/node_modules/react-native-share-menu/ios/ReactShareViewDelegate.swift
+++ b/node_modules/react-native-share-menu/ios/ReactShareViewDelegate.swift
@@ -10,5 +10,5 @@ public protocol ReactShareViewDelegate {
@@ -282,9 +290,8 @@ index 0aa4c58..d2bc970 100644
- func continueInApp(with item: NSExtensionItem, and extraData: [String:Any]?)
+ func continueInApp(with items: [NSExtensionItem], and extraData: [String:Any]?)
}
-\ No newline at end of file
diff --git a/node_modules/react-native-share-menu/ios/ShareViewController.swift b/node_modules/react-native-share-menu/ios/ShareViewController.swift
-index 7faf6e4..81aef73 100644
+index 7faf6e4..12d8c92 100644
--- a/node_modules/react-native-share-menu/ios/ShareViewController.swift
+++ b/node_modules/react-native-share-menu/ios/ShareViewController.swift
@@ -6,7 +6,9 @@
diff --git a/src/Screens.tsx b/src/Screens.tsx
index 6d90d6c8..9065ee5d 100644
--- a/src/Screens.tsx
+++ b/src/Screens.tsx
@@ -161,25 +161,18 @@ const Screens: React.FC = ({ localCorrupt }) => {
// Share Extension
const handleShare = useCallback(
- (item?: {
- extraData?: { share: { mimeType: string; data: string }[] }
- }) => {
+ (item?: { data?: { mimeType: string; data: string }[] }) => {
if (instanceActive < 0) {
return
}
- if (
- !item ||
- !item.extraData ||
- !Array.isArray(item.extraData.share) ||
- !item.extraData.share.length
- ) {
+ if (!item || !item.data || !Array.isArray(item.data) || !item.data) {
return
}
let text: string | undefined = undefined
let images: { type: string; uri: string }[] = []
let video: { type: string; uri: string } | undefined = undefined
- item.extraData.share.forEach((d, i) => {
+ item.data.forEach((d, i) => {
const typesImage = ['png', 'jpg', 'jpeg', 'gif']
const typesVideo = ['mp4', 'm4v', 'mov', 'webm']
const { mimeType, data } = d
@@ -219,12 +212,10 @@ const Screens: React.FC = ({ localCorrupt }) => {
[instanceActive]
)
useEffect(() => {
- console.log('getting intial share')
- ShareMenu.getInitialShare(handleShare)
+ ShareMenu.getInitialShare(item => handleShare(item))
}, [])
useEffect(() => {
- console.log('getting just share')
- const listener = ShareMenu.addNewShareListener(handleShare)
+ const listener = ShareMenu.addNewShareListener(item => handleShare(item))
return () => {
listener.remove()
}
diff --git a/src/ShareExtension.tsx b/src/ShareExtension.tsx
index ef9fdd00..621f1f69 100644
--- a/src/ShareExtension.tsx
+++ b/src/ShareExtension.tsx
@@ -1,9 +1,7 @@
-import { useEffect, useState } from 'react'
-import { Appearance, Platform, Pressable, Text } from 'react-native'
+import { useEffect } from 'react'
+import { Appearance, Pressable } from 'react-native'
import { Circle } from 'react-native-animated-spinkit'
-import RNFS from 'react-native-fs'
import { ShareMenuReactView } from 'react-native-share-menu'
-import uuid from 'react-native-uuid'
// mimeType
// text/plain - text only, website URL, video?!
@@ -21,58 +19,9 @@ const colors = {
}
}
-const clearDir = async (dir: string) => {
- try {
- const files = await RNFS.readDir(dir)
- for (const file of files) {
- await RNFS.unlink(file.path)
- }
- } catch (err: any) {
- console.warn(err.message)
- }
-}
-
const ShareExtension = () => {
- const [errorMessage, setErrorMessage] = useState()
-
useEffect(() => {
- ShareMenuReactView.data().then(async ({ data }) => {
- console.log('length', data.length)
- const newData = []
- switch (Platform.OS) {
- case 'ios':
- for (const d of data) {
- if (d.data.startsWith('file:///')) {
- const extension = d.data.split('.').pop()?.toLowerCase()
- const filename = `${uuid.v4()}.${extension}`
- const groupDirectory = await RNFS.pathForGroup(
- 'group.com.xmflsct.app.tooot'
- )
- await clearDir(groupDirectory)
- const newFilepath = `file://${groupDirectory}/${filename}`
- console.log('newFilepath', newFilepath)
- try {
- await RNFS.copyFile(d.data, newFilepath)
- newData.push({ ...d, data: newFilepath })
- } catch (err: any) {
- setErrorMessage(err.message)
- console.warn(err.message)
- }
- } else {
- newData.push(d)
- }
- }
- break
- case 'android':
- break
- default:
- return
- }
- console.log('new data', newData)
- if (!errorMessage) {
- ShareMenuReactView.continueInApp({ share: newData })
- }
- })
+ ShareMenuReactView.continueInApp()
}, [])
const theme = Appearance.getColorScheme() || 'light'
@@ -85,19 +34,8 @@ const ShareExtension = () => {
alignItems: 'center',
backgroundColor: colors.background[theme]
}}
- onPress={() => {
- if (errorMessage) {
- ShareMenuReactView.dismissExtension(errorMessage)
- }
- }}
>
- {!errorMessage ? (
-
- {errorMessage}
-
- ) : (
-
- )}
+
)
}
diff --git a/yarn.lock b/yarn.lock
index 26276575..7d88160e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2425,9 +2425,9 @@ async-limiter@~1.0.0:
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==
async@^2.4.0:
- version "2.6.3"
- resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
- integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
+ version "2.6.4"
+ resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
+ integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==
dependencies:
lodash "^4.17.14"
@@ -2576,11 +2576,6 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
-base-64@^0.1.0:
- version "0.1.0"
- resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb"
- integrity sha1-eAqZyE59YAJgNhURxId2E78k9rs=
-
base64-js@^1.1.2, base64-js@^1.2.3, base64-js@^1.3.0, base64-js@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
@@ -2621,13 +2616,6 @@ bplist-creator@0.1.0:
dependencies:
stream-buffers "2.2.x"
-bplist-parser@0.3.0:
- version "0.3.0"
- resolved "https://registry.yarnpkg.com/bplist-parser/-/bplist-parser-0.3.0.tgz#ba50666370f61bbf94881636cd9f7d23c5286090"
- integrity sha512-zgmaRvT6AN1JpPPV+S0a1/FAtoxSreYDccZGIqEMSvZl9DMe70mJ7MFzpxa1X+gHVdkToE2haRUHHMiW1OdejA==
- dependencies:
- big-integer "1.6.x"
-
bplist-parser@0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/bplist-parser/-/bplist-parser-0.3.1.tgz#e1c90b2ca2a9f9474cc72f6862bbf3fee8341fd1"
@@ -6057,7 +6045,7 @@ pkg-up@^3.1.0:
dependencies:
find-up "^3.0.0"
-plist@^3.0.2, plist@^3.0.4, plist@^3.0.5:
+plist@^3.0.2, plist@^3.0.5:
version "3.0.5"
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.5.tgz#2cbeb52d10e3cdccccf0c11a63a85d830970a987"
integrity sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==
@@ -6302,14 +6290,6 @@ react-native-flash-message@0.2.1:
prop-types "^15.8.1"
react-native-iphone-x-helper "^1.3.1"
-react-native-fs@^2.19.0:
- version "2.19.0"
- resolved "https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.19.0.tgz#5747eb52a5a3d2b31c8fb76f5f8044d0a855122c"
- integrity sha512-Yl09IbETkV5UJcBtVtBLttyTmiAhJIHpGA/LvredI5dYiw3MXMMVu42bzELiuH2Bwj7F+qd0fMNvgfBDiDxd2A==
- dependencies:
- base-64 "^0.1.0"
- utf8 "^3.0.0"
-
react-native-gesture-handler@2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.4.1.tgz#f4cb1784b6dcdf41ae35b4fff6022ec21038e2cd"
@@ -6388,11 +6368,6 @@ react-native-tab-view@3.1.1:
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-3.1.1.tgz#1f8d7a835ab4f5b1b1407ec8dddc1053b53fa3c6"
integrity sha512-M5pRN6utQfytKWoKlKVzg5NbkYu308qNoW1khGTtEOTs1k14p2dHJ/BWOJoJYHKbPVUyZldbG9MFT7gUl4YHnw==
-react-native-uuid@^2.0.1:
- version "2.0.1"
- resolved "https://registry.yarnpkg.com/react-native-uuid/-/react-native-uuid-2.0.1.tgz#ed4e2dfb1683eddb66967eb5dca140dfe1abddb9"
- integrity sha512-cptnoIbL53GTCrWlb/+jrDC6tvb7ypIyzbXNJcpR3Vab0mkeaaVd5qnB3f0whXYzS+SMoSQLcUUB0gEWqkPC0g==
-
react-native@0.67.4:
version "0.67.4"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.67.4.tgz#57a1503daa81f66a61f521ff67b259f126d87f9c"
@@ -6934,7 +6909,7 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
-simple-plist@^1.0.0:
+simple-plist@^1.0.0, simple-plist@^1.1.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.3.1.tgz#16e1d8f62c6c9b691b8383127663d834112fb017"
integrity sha512-iMSw5i0XseMnrhtIzRb7XpQEXepa9xhWxGUojHBL43SIpQuDQkh3Wpy67ZbDzZVr6EKxvwVChnVpdl8hEVLDiw==
@@ -6943,15 +6918,6 @@ simple-plist@^1.0.0:
bplist-parser "0.3.1"
plist "^3.0.5"
-simple-plist@^1.1.0:
- version "1.3.0"
- resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.3.0.tgz#f451997663eafd8ea6bad353a01caf49ef186d43"
- integrity sha512-uYWpeGFtZtVt2NhG4AHgpwx323zxD85x42heMJBan1qAiqqozIlaGrwrEt6kRjXWRWIXsuV1VLCvVmZan2B5dg==
- dependencies:
- bplist-creator "0.1.0"
- bplist-parser "0.3.0"
- plist "^3.0.4"
-
simple-swizzle@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"
@@ -7550,11 +7516,6 @@ use@^3.1.0:
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==
-utf8@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1"
- integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==
-
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"