Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit b7da4a5

Browse files
committed
fix(doramon): link community/user in search results
1 parent ce86a46 commit b7da4a5

File tree

2 files changed

+42
-28
lines changed

2 files changed

+42
-28
lines changed

containers/Doraemon/helper/advisor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class Advisor {
115115

116116
relateSuggestions = val => {
117117
// sync with store allSuggestions
118+
console.log('the fuck????')
118119
this.curSuggestions = this.store.allSuggestions
119120

120121
return {

containers/Doraemon/logic.js

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,29 +183,7 @@ const initSpecCmdResolver = () => {
183183
match: SAK.communityLinker,
184184
action: cmdpath => {
185185
const community = cmdpath[0]
186-
const { mainPath, subPath } = store.curRoute
187-
188-
if (
189-
R.contains(mainPath, [ROUTE.USER, ROUTE.COMMUNITIES]) ||
190-
R.contains(subPath, [ROUTE.POST, ROUTE.JOB, ROUTE.VIDEO, ROUTE.REPO])
191-
) {
192-
Global.location.href = `/${community}/posts`
193-
return hidePanel()
194-
}
195-
196-
store.setViewing({
197-
community: { raw: community },
198-
activeThread: THREAD.POST,
199-
post: {},
200-
})
201-
202-
store.markRoute({
203-
mainPath: community,
204-
subPath: thread2Subpath(THREAD.POST),
205-
})
206-
207-
dispatchEvent(EVENT.COMMUNITY_CHANGE)
208-
hidePanel()
186+
jumpToCommunity(community)
209187
},
210188
},
211189
{
@@ -218,6 +196,7 @@ const initSpecCmdResolver = () => {
218196
}
219197

220198
const doSpecCmd = () => {
199+
if (store.searching) return false
221200
const cmd = store.curCmdChain
222201
if (!cmd) return
223202

@@ -233,16 +212,23 @@ const doSpecCmd = () => {
233212
}
234213

235214
const doNavigate = () => {
236-
const { id } = store.activeSuggestion
215+
if (store.searching) return false
216+
// const { id } = store.activeSuggestion
237217
if (R.startsWith('user-raw', store.activeSuggestion.raw)) {
218+
const { raw } = store.activeSuggestion
219+
const login = raw.split('user-raw-')[1]
238220
hidePanel()
221+
239222
return dispatchEvent(EVENT.PREVIEW_OPEN, {
240223
type: TYPE.PREVIEW_USER_VIEW,
241-
data: { id },
224+
data: { login },
242225
})
243226
}
244227

245-
debug('doNavigate cmd: ', store.activeSuggestion)
228+
if (store.searchThread === 'community') {
229+
const { raw: communityRaw } = store.activeSuggestion
230+
jumpToCommunity(communityRaw)
231+
}
246232
}
247233

248234
export const handleShortCuts = e => {
@@ -324,6 +310,32 @@ const convert2Sugguestions = (data, searchedTotalCount) => {
324310
store.loadSuggestions({ prefix: '', data })
325311
}
326312

313+
const jumpToCommunity = communityRaw => {
314+
const { mainPath, subPath } = store.curRoute
315+
316+
if (
317+
R.contains(mainPath, [ROUTE.USER, ROUTE.COMMUNITIES]) ||
318+
R.contains(subPath, [ROUTE.POST, ROUTE.JOB, ROUTE.VIDEO, ROUTE.REPO])
319+
) {
320+
Global.location.href = `/${communityRaw}/posts`
321+
return hidePanel()
322+
}
323+
324+
store.setViewing({
325+
community: { raw: communityRaw },
326+
activeThread: THREAD.POST,
327+
post: {},
328+
})
329+
330+
store.markRoute({
331+
mainPath: communityRaw,
332+
subPath: thread2Subpath(THREAD.POST),
333+
})
334+
335+
dispatchEvent(EVENT.COMMUNITY_CHANGE)
336+
hidePanel()
337+
}
338+
327339
// ###############################
328340
// Data & Error handlers
329341
// ###############################
@@ -352,7 +364,8 @@ const DataSolver = [
352364
e => ({
353365
id: e.id,
354366
logo: e.logo,
355-
raw: `community-raw-${e.id}`,
367+
// raw: `community-raw-${e.id}`,
368+
raw: `${e.raw}`,
356369
title: e.title,
357370
desc: `${e.desc}`,
358371
}),
@@ -369,7 +382,7 @@ const DataSolver = [
369382
e => ({
370383
id: e.id,
371384
logo: e.avatar,
372-
raw: `user-raw-${e.id}`,
385+
raw: `user-raw-${e.login}`,
373386
title: e.nickname,
374387
desc: `${e.bio}`,
375388
}),

0 commit comments

Comments
 (0)