Skip to content

Commit 02aaf2c

Browse files
authored
dont blank out avatars. dont show api errors on avatars. fix for black bars where x would disappear (keybase#10372)
* dont blank out avatars. dont show api errors on avatars. fix for black bars where x would disappear * WIP * WIP
1 parent 219875c commit 02aaf2c

7 files changed

Lines changed: 28 additions & 45 deletions

File tree

‎shared/actions/config-gen.js‎

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎shared/actions/config.js‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ function _bootstrapSuccess(action: ConfigGen.BootstrapSuccessPayload, state: Typ
212212
return Saga.sequentially(actions)
213213
}
214214

215-
function _loadAvatarHelper(action: {payload: {names: Array<string>, endpoint: string, key: string}}) {
215+
type AvatarHelperAction = {payload: {names: Array<string>, endpoint: string, key: string}}
216+
function _loadAvatarHelper(action: AvatarHelperAction) {
216217
const {names, endpoint, key} = action.payload
217218
return Saga.sequentially([
218219
Saga.call(RPCTypes.apiserverGetRpcPromise, {
@@ -223,7 +224,16 @@ function _loadAvatarHelper(action: {payload: {names: Array<string>, endpoint: st
223224
])
224225
}
225226

226-
function _afterLoadAvatarHelper([response: {body: string}, names]) {
227+
function _loadAvatarHelperError(error: Error, action: AvatarHelperAction) {
228+
// Ignore api errors
229+
if (error.code === RPCTypes.constantsStatusCode.scapinetworkerror) {
230+
throw error // TEMP
231+
} else {
232+
throw error
233+
}
234+
}
235+
236+
function _loadAvatarHelperSuccess([response: {body: string}, names]) {
227237
const nameToUrlMap = JSON.parse(response.body).pictures.reduce((map, picMap, idx) => {
228238
const name = names[idx]
229239
const urlMap = {
@@ -284,14 +294,6 @@ function* _loadTeamAvatars(action: ConfigGen.LoadTeamAvatarsPayload) {
284294
}
285295
}
286296

287-
// Every minute we clear out any avatars that might have errored out
288-
function* _periodicAvatarCacheClear(): Generator<any, void, any> {
289-
while (true) {
290-
yield Saga.call(Saga.delay, 1000 * 60)
291-
yield Saga.put(ConfigGen.createClearAvatarCache())
292-
}
293-
}
294-
295297
function _setOpenAtLogin(action: ConfigGen.SetOpenAtLoginPayload) {
296298
if (action.payload.writeFile) {
297299
setAppState({openAtLogin: action.payload.open})
@@ -313,9 +315,13 @@ function* configSaga(): Saga.SagaGenerator<any, any> {
313315
yield Saga.safeTakeEveryPure(ConfigGen.retryBootstrap, _retryBootstrap)
314316
yield Saga.safeTakeEvery(ConfigGen.loadAvatars, _loadAvatars)
315317
yield Saga.safeTakeEvery(ConfigGen.loadTeamAvatars, _loadTeamAvatars)
316-
yield Saga.safeTakeEveryPure('_loadAvatarHelper', _loadAvatarHelper, _afterLoadAvatarHelper)
318+
yield Saga.safeTakeEveryPure(
319+
'_loadAvatarHelper',
320+
_loadAvatarHelper,
321+
_loadAvatarHelperSuccess,
322+
_loadAvatarHelperError
323+
)
317324
yield Saga.safeTakeEveryPure(ConfigGen.setOpenAtLogin, _setOpenAtLogin)
318-
yield Saga.fork(_periodicAvatarCacheClear)
319325
yield Saga.fork(_getAppState)
320326
}
321327

‎shared/actions/gregor.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function registerReachability() {
5252
// without re-bootstrapping. Originally we used to do this on HTML5
5353
// 'online' event, but reachability is more precise.
5454
dispatch(ConfigGen.createBootstrap({isReconnect: true}))
55-
dispatch(ConfigGen.createClearAvatarCache())
5655
}
5756
}
5857
})

‎shared/actions/json/config.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"import * as Types from '../constants/types/config'"
44
],
55
"actions": {
6-
"clearAvatarCache": {},
76
"loadAvatars": {
87
"usernames": "Array<string>"
98
},

‎shared/app/global-errors/index.native.js‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,18 @@ class GlobalError extends Component<Props, State> {
101101
<Box style={{...containerStyle, maxHeight}}>
102102
<NativeTouchableWithoutFeedback onPress={this._onExpandClick}>
103103
<Box style={summaryRowStyle}>
104-
{summary && (
105-
<Icon
106-
type="iconfont-exclamation"
107-
style={{color: globalColors.white, marginRight: globalMargins.tiny}}
108-
/>
109-
)}
104+
<Icon
105+
type="iconfont-exclamation"
106+
style={{color: globalColors.white, marginRight: globalMargins.tiny}}
107+
/>
110108
<Text type="BodySmall" style={{color: globalColors.white, flex: 1, textAlign: 'center'}}>
111109
{summary}
112110
</Text>
113-
{summary && (
114-
<Icon
115-
type="iconfont-close"
116-
onClick={onDismiss}
117-
style={{color: globalColors.white_75, marginLeft: globalMargins.tiny}}
118-
/>
119-
)}
111+
<Icon
112+
type="iconfont-close"
113+
onClick={onDismiss}
114+
style={{color: globalColors.white_75, marginLeft: globalMargins.tiny}}
115+
/>
120116
</Box>
121117
</NativeTouchableWithoutFeedback>
122118
<NativeScrollView>
@@ -146,6 +142,7 @@ const summaryRowStyle = {
146142
...globalStyles.flexBoxRow,
147143
alignItems: 'flex-start',
148144
justifyContent: 'flex-start',
145+
flexShrink: 0,
149146
minHeight: GlobalError.maxHeightForSize('Small'),
150147
padding: globalMargins.tiny,
151148
paddingTop: globalMargins.medium,

‎shared/logger/action-transformer.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ const actionTransformMap: {[key: string]: ActionTransformer<*, *>} = {
145145
'entity:subtract': entityTransformer,
146146
_loadAvatarHelper: nullTransform,
147147
[ChatGen.clearRekey]: nullTransform,
148-
[ConfigGen.clearAvatarCache]: nullTransform,
149148
[ConfigGen.loadAvatars]: nullTransform,
150149
[ConfigGen.loadTeamAvatars]: nullTransform,
151150
[ConfigGen.loadedAvatars]: nullTransform,

‎shared/reducers/config.js‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import * as Types from '../constants/types/config'
55
import * as Constants from '../constants/config'
66
import * as ConfigGen from '../actions/config-gen'
77
import * as AppGen from '../actions/app-gen'
8-
import isEmpty from 'lodash/isEmpty'
9-
import pickBy from 'lodash/pickBy'
108

119
const initialState = Constants.makeState()
1210

@@ -82,17 +80,6 @@ export default function(
8280
.set('appFocusedCount', state.appFocusedCount + 1)
8381
case AppGen.changedActive:
8482
return state.set('userActive', action.payload.userActive)
85-
case ConfigGen.clearAvatarCache: {
86-
const old = state.avatars
87-
const goodAvatars = pickBy(old, value => !isEmpty(value))
88-
89-
if (Object.keys(old).length === Object.keys(goodAvatars).length) {
90-
return state
91-
} else {
92-
// Something errored?
93-
return state.set('avatars', goodAvatars)
94-
}
95-
}
9683
case ConfigGen.loadedAvatars: {
9784
const {nameToUrlMap} = action.payload
9885
return state.set('avatars', {

0 commit comments

Comments
 (0)