From 1eec539e35ab0f81740c7b4b03a67109e3f5a2f8 Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Mon, 24 Feb 2020 22:09:48 -0800 Subject: [PATCH] move to deeplinks --- shared/actions/deeplinks-gen.tsx | 15 ++++++--------- shared/actions/deeplinks.tsx | 12 +++++++----- shared/actions/json/deeplinks.json | 2 +- shared/actions/typed-actions-gen.tsx | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/shared/actions/deeplinks-gen.tsx b/shared/actions/deeplinks-gen.tsx index 7a8712866e8e..c05162673f31 100644 --- a/shared/actions/deeplinks-gen.tsx +++ b/shared/actions/deeplinks-gen.tsx @@ -3,13 +3,13 @@ // Constants export const resetStore = 'common:resetStore' // not a part of deeplinks but is handled by every reducer. NEVER dispatch this export const typePrefix = 'deeplinks:' -export const handleFileLink = 'deeplinks:handleFileLink' +export const handleFile = 'deeplinks:handleFile' export const handleKeybaseLink = 'deeplinks:handleKeybaseLink' export const link = 'deeplinks:link' export const setKeybaseLinkError = 'deeplinks:setKeybaseLinkError' // Payload Types -type _HandleFileLinkPayload = {readonly path: string} +type _HandleFilePayload = {readonly path: string} type _HandleKeybaseLinkPayload = {readonly link: string} type _LinkPayload = {readonly link: string} type _SetKeybaseLinkErrorPayload = {readonly error: string} @@ -21,9 +21,9 @@ type _SetKeybaseLinkErrorPayload = {readonly error: string} export const createSetKeybaseLinkError = ( payload: _SetKeybaseLinkErrorPayload ): SetKeybaseLinkErrorPayload => ({payload, type: setKeybaseLinkError}) -export const createHandleFileLink = (payload: _HandleFileLinkPayload): HandleFileLinkPayload => ({ +export const createHandleFile = (payload: _HandleFilePayload): HandleFilePayload => ({ payload, - type: handleFileLink, + type: handleFile, }) export const createHandleKeybaseLink = (payload: _HandleKeybaseLinkPayload): HandleKeybaseLinkPayload => ({ payload, @@ -32,10 +32,7 @@ export const createHandleKeybaseLink = (payload: _HandleKeybaseLinkPayload): Han export const createLink = (payload: _LinkPayload): LinkPayload => ({payload, type: link}) // Action Payloads -export type HandleFileLinkPayload = { - readonly payload: _HandleFileLinkPayload - readonly type: typeof handleFileLink -} +export type HandleFilePayload = {readonly payload: _HandleFilePayload; readonly type: typeof handleFile} export type HandleKeybaseLinkPayload = { readonly payload: _HandleKeybaseLinkPayload readonly type: typeof handleKeybaseLink @@ -49,7 +46,7 @@ export type SetKeybaseLinkErrorPayload = { // All Actions // prettier-ignore export type Actions = - | HandleFileLinkPayload + | HandleFilePayload | HandleKeybaseLinkPayload | LinkPayload | SetKeybaseLinkErrorPayload diff --git a/shared/actions/deeplinks.tsx b/shared/actions/deeplinks.tsx index 3260a786c4ef..b61486a90d31 100644 --- a/shared/actions/deeplinks.tsx +++ b/shared/actions/deeplinks.tsx @@ -1,7 +1,8 @@ import * as ChatGen from './chat2-gen' import * as Constants from '../constants/config' import * as Container from '../util/container' -import * as CryptoTypes from '../' +import * as CryptoGen from '../actions/crypto-gen' +import * as CryptoTypes from '../constants/types/crypto' import * as DeeplinksGen from './deeplinks-gen' import * as Platform from '../constants/platform' import * as ProfileGen from './profile-gen' @@ -10,6 +11,7 @@ import * as Saga from '../util/saga' import * as Tabs from '../constants/tabs' import * as WalletsGen from './wallets-gen' import * as TeamsGen from './teams-gen' +import HiddenString from '../util/hidden-string' import URL from 'url-parse' import logger from '../logger' @@ -135,7 +137,7 @@ const handleAppLink = (state: Container.TypedState, action: DeeplinksGen.LinkPay return false } -const handleFile = (state: Container.TypedState, action: DeeplinksGen.FilePayload) => { +const handleFile = (action: DeeplinksGen.HandleFilePayload) => { let operation: CryptoTypes.Operations const {path} = action.payload if (path.endsWith('.encrypted.saltpack')) { @@ -144,13 +146,13 @@ const handleFile = (state: Container.TypedState, action: DeeplinksGen.FilePayloa operation = 'verify' } else { console.warn('Received a filename with an unknown extension: ', path) - return + return false } - return DeeplinksGen.createSetInputThrottled({operation, type: 'file', value: new HiddenString(path)}) + return CryptoGen.createSetInputThrottled({operation, type: 'file', value: new HiddenString(path)}) } function* deeplinksSaga() { - yield* Saga.chainAction2(DeeplinksGen.handleFile, handleFile) + yield* Saga.chainAction(DeeplinksGen.handleFile, handleFile) yield* Saga.chainAction2(DeeplinksGen.link, handleAppLink) yield* Saga.chainAction(DeeplinksGen.handleKeybaseLink, handleKeybaseLink) } diff --git a/shared/actions/json/deeplinks.json b/shared/actions/json/deeplinks.json index 9138ad19987f..bf33bd1c2aba 100644 --- a/shared/actions/json/deeplinks.json +++ b/shared/actions/json/deeplinks.json @@ -1,7 +1,7 @@ { "prelude": [], "actions": { - "handleFileLink": {"path": "string"}, + "handleFile": {"path": "string"}, "handleKeybaseLink": {"link": "string"}, "link": {"link": "string"}, "setKeybaseLinkError": { diff --git a/shared/actions/typed-actions-gen.tsx b/shared/actions/typed-actions-gen.tsx index 8eb3a8e1c525..d61294cc12eb 100644 --- a/shared/actions/typed-actions-gen.tsx +++ b/shared/actions/typed-actions-gen.tsx @@ -325,7 +325,7 @@ export type TypedActionsMap = { 'crypto:saltpackSign': crypto.SaltpackSignPayload 'crypto:saltpackStart': crypto.SaltpackStartPayload 'crypto:saltpackVerify': crypto.SaltpackVerifyPayload - 'deeplinks:handleFileLink': deeplinks.HandleFileLinkPayload + 'deeplinks:handleFile': deeplinks.HandleFilePayload 'deeplinks:handleKeybaseLink': deeplinks.HandleKeybaseLinkPayload 'deeplinks:link': deeplinks.LinkPayload 'deeplinks:setKeybaseLinkError': deeplinks.SetKeybaseLinkErrorPayload