-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More gen 22: Flow coverage exploration #9575
More gen 22: Flow coverage exploration #9575
Conversation
@@ -17,7 +17,7 @@ export const mobileAppState = 'app:mobileAppState' | |||
export const createChangedActive = (payload: {|+userActive: boolean|}) => ({error: false, payload, type: changedActive}) | |||
export const createChangedFocus = (payload: {|+appFocused: boolean|}) => ({error: false, payload, type: changedFocus}) | |||
export const createLink = (payload: {|+link: string|}) => ({error: false, payload, type: link}) | |||
export const createMobileAppState = (payload: {|+nextAppState: string|}) => ({error: false, payload, type: mobileAppState}) | |||
export const createMobileAppState = (payload: {|+nextAppState: 'active' | 'background' | 'inactive'|}) => ({error: false, payload, type: mobileAppState}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from RN docs
@@ -151,7 +151,7 @@ export const createSaveAttachment = (payload: {|+messageKey: Types.MessageKey|}) | |||
export const createSaveAttachmentNative = (payload: {|+messageKey: Types.MessageKey|}) => ({error: false, payload, type: saveAttachmentNative}) | |||
export const createSelectAttachment = (payload: {|+input: Types.AttachmentInput|}) => ({error: false, payload, type: selectAttachment}) | |||
export const createSelectConversation = (payload: {|+conversationIDKey: ?Types.ConversationIDKey, +fromUser?: boolean|}) => ({error: false, payload, type: selectConversation}) | |||
export const createSelectNext = (payload: {|+rows: Array<any>, +direction: -1 | 1|}) => ({error: false, payload, type: selectNext}) | |||
export const createSelectNext = (payload: {|+rows: Array<{conversationIDKey: Types.ConversationIDKey}>, +direction: -1 | 1|}) => ({error: false, payload, type: selectNext}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really we care about pulling the convoId out
@@ -40,6 +40,7 @@ const _getInboxQuery = { | |||
// Update inboxes that have been reset | |||
function* _updateFinalized(inbox: RPCChatTypes.UnverifiedInboxUIItems): Generator<any, void, any> { | |||
const finalizedState: Types.FinalizedState = I.Map( | |||
// TODO i *think* this typing is totally incorrect. should be .items etc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong
@@ -387,7 +392,7 @@ function* _chatInboxFailedSubSaga(params) { | |||
? I.List([].concat(error.rekeyInfo.writerNames, error.rekeyInfo.readerNames).filter(Boolean)) | |||
: I.List(error.unverifiedTLFName.split(',')), | |||
status: 'unfiled', | |||
time: error.remoteConv.readerInfo.mtime, | |||
time: error.remoteConv.readerInfo ? error.remoteConv.readerInfo.mtime : 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avdl says this can be missing
@@ -650,7 +655,7 @@ function* _sendNotifications(action: ChatGen.AppendMessagesPayload): Saga.SagaGe | |||
if (message && message.type === 'Text') { | |||
console.log('Sending Chat notification') | |||
const snippet = Constants.makeSnippet(Constants.serverMessageToMessageText(message)) | |||
yield Saga.put((dispatch: Dispatch) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use Dispatch globally a lot but its really untyped. The one from redux also doesn't understand thunks
@@ -42,9 +42,12 @@ function* deleteMessage(action: ChatGen.DeleteMessagePayload): SagaGenerator<any | |||
} | |||
const tlfName: string = inboxConvo.name | |||
|
|||
const parsedMessageID = lastMessageID ? Constants.parseMessageID(lastMessageID) : null | |||
const clientPrev = parsedMessageID && parsedMessageID.type === 'rpcMessageID' ? parsedMessageID.msgID : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only valid clientPrevs are from real messages and not the other things in the stream
@@ -386,7 +386,7 @@ function _unboxedToMessage( | |||
: null | |||
// $FlowIssue | |||
const messageText: ChatTypes.MessageText = message.outbox.body | |||
const outboxIDKey = payload.outboxID && Constants.outboxIDToKey(payload.outboxID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outboxIDKeys are already coming down as the hex strings
@@ -1,6 +1,5 @@ | |||
// @flow | |||
import {RPCError} from '../util/errors' | |||
import {Buffer} from 'buffer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we caused the confusion w/ Buffer
totals[conversationIDKey] = total | ||
if (badged) { | ||
badges[conversationIDKey] = badged | ||
const convID = conv.get('convID') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likely never null in practice but is possible
@@ -156,7 +156,7 @@ const _onTabChange = (action: RouteTreeTypes.SwitchTo) => { | |||
} | |||
|
|||
function* _handleIncomingGregor(action: GitGen.HandleIncomingGregorPayload): Saga.SagaGenerator<any, any> { | |||
const msgs = action.payload.messages.map(msg => JSON.parse(msg.body)) | |||
const msgs = action.payload.messages.map(msg => JSON.parse(msg.body.toString())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this worked before because the buffer is essentially casting to a string implicitly using toString() but this thing really is a buffer
const createdTLFs = msgsWithParsedBodies.filter(m => m.body.action === 'create') | ||
|
||
const username: string = (yield Saga.select(usernameSelector): any) | ||
const createdTLFs: Array<{action: string, tlf: ?string}> = kbfsFavoriteMessages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flow got confused when we overwrote the body prop with a new body. we don't even use the raw ...m part so lets just get rid of it
@@ -371,9 +371,8 @@ function _afterGetChannels( | |||
|
|||
const convs = results.convs || [] | |||
convs.forEach(conv => { | |||
const convID = ChatConstants.conversationIDToKey(conv.convID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conv.convID is actually a string already
ChatConstants.keyToConversationID(channelnameToConvID[channelname]), | ||
}) | ||
}) | ||
const convID = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rpc needs this to be non null
convID, | ||
}) | ||
} | ||
}).filter(Boolean) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filtering this cause we can return from map w/ undefined
@@ -26,7 +27,9 @@ const getIsEmpty = (state: TypedState) => state.chat.get('inboxIsEmpty') | |||
const getPending = (state: TypedState) => state.chat.get('pendingConversations') | |||
const getSmallTimestamps = (state: TypedState) => state.chat.getIn(['inboxSmallTimestamps'], I.Map()) | |||
const getSupersededBy = (state: TypedState) => state.chat.get('inboxSupersededBy') | |||
const _rowsForSelect = (rows: Array<any>) => rows.filter(r => ['small', 'big'].includes(r.type)) | |||
const _rowsForSelect = (rows: Array<Inbox.RowItem>): Array<Inbox.RowItemSmall | Inbox.RowItemBig> => | |||
// $FlowIssue doesn't underestand filter refinement sadly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch, {focusFilter, routeState, setRouteState}) => ({ | ||
const mapDispatchToProps = (dispatch: any => void, {focusFilter, routeState, setRouteState}: OwnProps) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO (later) we could update our dispatch type
@@ -114,54 +59,18 @@ function maybeUpgradeSearchResultIdToKeybaseId( | |||
return id | |||
} | |||
|
|||
function platformToIcon(service: Service): IconType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are never used
@@ -0,0 +1,37 @@ | |||
// @flow | |||
// Sep. engine file so we can avoid import cycles w/ flow-types.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flow-types pulls in engine which pulls in flow-types etc, lets not have that happen
@keybase/react-hackers this is ready |
I merged 21 and below so this needs to be reopened vs master |
99ae001
to
4aff76f
Compare
replaced by #9685 |
Did some analysis of the flow coverage and found some underlying issues
Chat
Search/Teams:
Split the constants/types to remove cyclic dependencies in flow (if you run flow check --profile it'll tell you when it detects one)