Skip to content

Commit 17d7a3f

Browse files
authored
Merge pull request #5556 from nextcloud/fix/navigate-to-userprofile
fix(router): redirect profile details view to internal contacts list
2 parents 062cf2e + 812eeb7 commit 17d7a3f

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/models/contact.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export const MinimalContactProperties = [
2828
'EMAIL', 'UID', 'TEL', 'CATEGORIES', 'FN', 'ORG', 'N', 'X-PHONETIC-FIRST-NAME', 'X-PHONETIC-LAST-NAME', 'X-MANAGERSNAME', 'TITLE', 'NOTE', 'RELATED',
2929
].concat(ContactKindProperties)
3030

31+
export function generateContactKey(uid, addressbookId) {
32+
return Buffer.from(uid + '~' + addressbookId, 'utf8').toString('base64')
33+
}
34+
3135
export default class Contact {
3236
/**
3337
* Creates an instance of Contact
@@ -211,7 +215,7 @@ export default class Contact {
211215
* @memberof Contact
212216
*/
213217
get key() {
214-
return Buffer.from(this.uid + '~' + this.addressbook.id, 'utf8').toString('base64')
218+
return generateContactKey(this.uid, this.addressbook.id)
215219
}
216220

217221
/**

src/router/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import { generateUrl } from '@nextcloud/router'
77
import { createRouter, createWebHistory } from 'vue-router'
88
import Contacts from '../views/Contacts.vue'
9-
import { ROUTE_CHART, ROUTE_CIRCLE, ROUTE_USER_GROUP } from '../models/constants.ts'
9+
import { GROUP_ALL_CONTACTS, ROUTE_CHART, ROUTE_CIRCLE, ROUTE_USER_GROUP } from '../models/constants.ts'
10+
import { generateContactKey } from '../models/contact.js'
1011

1112
// if index.php is in the url AND we got this far, then it's working:
1213
// let's keep using index.php in the url
@@ -57,6 +58,17 @@ export default createRouter({
5758
name: 'user_group',
5859
component: Contacts,
5960
},
61+
{
62+
path: 'u/:userId',
63+
name: 'profile-redirect',
64+
redirect: (to) => ({
65+
name: 'contact',
66+
params: {
67+
selectedGroup: GROUP_ALL_CONTACTS,
68+
selectedContact: generateContactKey(to.params.userId, 'z-server-generated--system'),
69+
},
70+
}),
71+
},
6072
],
6173
},
6274
],

0 commit comments

Comments
 (0)