-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
109 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; | ||
import { createAsyncThunk, createSlice, RootState } from "@reduxjs/toolkit"; | ||
import { Post } from "@gno/types"; | ||
import * as Linking from 'expo-linking'; | ||
import { ThunkExtra } from "redux/redux-provider"; | ||
interface State { | ||
postToReply: Post | undefined; | ||
} | ||
|
||
const initialState: State = { | ||
postToReply: undefined, | ||
}; | ||
|
||
export const requestAddressForGnokeyMobile = createAsyncThunk<Promise<boolean>>("tx/requestAddressForGnokeyMobile", () => { | ||
export const requestAddressForGnokeyMobile = createAsyncThunk<boolean>("tx/requestAddressForGnokeyMobile", async () => { | ||
console.log("requesting address for GnokeyMobile"); | ||
const callback = encodeURIComponent('tech.berty.dsocial://post'); | ||
return Linking.openURL(`land.gno.gnokey://toselect?callback=${callback}`); | ||
return await Linking.openURL(`land.gno.gnokey://toselect?callback=${callback}`); | ||
}); | ||
|
||
export const broadcastTxCommit = createAsyncThunk<void, string, ThunkExtra>("tx/broadcastTxCommit", async (signedTx, thunkAPI) => { | ||
console.log("broadcasting tx: ", signedTx); | ||
|
||
const gnonative = thunkAPI.extra.gnonative; | ||
|
||
await gnonative.broadcastTxCommit(signedTx); | ||
}); | ||
|
||
export const txSlice = createSlice({ | ||
name: "tx", | ||
initialState, | ||
reducers: {}, | ||
selectors: { | ||
selectPostToReply: (state) => state.postToReply, | ||
}, | ||
extraReducers(builder) { | ||
// builder.addCase(setPostToReply.fulfilled, (state, action) => { | ||
// state.postToReply = action.payload.post; | ||
// }); | ||
// builder.addCase(setPostToReply.rejected, (state, action) => { | ||
// console.log("Error while replying a post, please, check the logs. %s", action.error.message); | ||
// }); | ||
}, | ||
selectors: {} | ||
}); | ||
|
||
// export const { selectPostToReply } = txSlice.selectors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as Linking from 'expo-linking'; | ||
import { useEffect } from 'react'; | ||
|
||
|
||
const LinkingProvider = ({ children }: { children: React.ReactNode }) => { | ||
const url = Linking.useURL(); | ||
|
||
// const dispatch = useAppDispatch(); | ||
|
||
useEffect(() => { | ||
if (url) { | ||
const { hostname, path, queryParams } = Linking.parse(url); | ||
|
||
console.log("link url", url); | ||
console.log("link hostname", hostname); | ||
console.log("link path", path); | ||
console.log("link queryParams", queryParams); | ||
|
||
if (queryParams) { | ||
|
||
// if (queryParams.tx && typeof queryParams.tx === "string") { | ||
// dispatch(setTxInput({ txInput: queryParams.tx })); | ||
// } | ||
|
||
// if (queryParams.callback && typeof queryParams.callback === "string") { | ||
// dispatch(setCallback({ callback: decodeURIComponent(queryParams.callback) })); | ||
// } | ||
} | ||
} | ||
}, [url]); | ||
|
||
return <>{children}</>; | ||
}; | ||
|
||
export { LinkingProvider }; |