Skip to content

Commit 37dee78

Browse files
authored
fix: apply onProfileEditSuccess props (#855)
[UIKIT-4542](https://sendbird.atlassian.net/browse/UIKIT-4542) Also, internal troubleshooting ### Issue * The props, `onProfileEditSuccess` has been not applied.. ### Fix * Apply the `onProfileEditSuccess` props to the App and ChannelList components * Apply the profile edition in the Integrated App storybook sample ### ChangeLog * Apply the `onProfileEditSuccess` props to the App and ChannelList components [UIKIT-4542]: https://sendbird.atlassian.net/browse/UIKIT-4542?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 9dc34c9 commit 37dee78

File tree

4 files changed

+38
-20
lines changed

4 files changed

+38
-20
lines changed

src/modules/App/stories/integrated.stories.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ import { MediaQueryProvider } from '../../../lib/MediaQueryContext';
1313

1414
const STORAGE_KEY = 'sendbird-integrated-app-v1-groupchannel';
1515

16+
function storeCurrentSampleOptions({
17+
store,
18+
sampleOptions,
19+
globalEnvironments,
20+
}) {
21+
store.current.setItem(STORAGE_KEY, JSON.stringify({
22+
login: false,
23+
currentAppId: sampleOptions.appId,
24+
apps: {
25+
...globalEnvironments?.apps,
26+
[sampleOptions.appId]: {
27+
currentUserId: sampleOptions.userId,
28+
users: {
29+
...globalEnvironments?.apps?.[sampleOptions.appId]?.users,
30+
[sampleOptions.userId]: sampleOptions,
31+
},
32+
},
33+
},
34+
}));
35+
}
36+
1637
/**
1738
* Polyfill for localStorage
1839
* localStorage wont work in some browsers, in incognito
@@ -304,20 +325,7 @@ export const GroupChannel = () => {
304325
<div className={`sendbird-integrated-sample-app sendbird-theme--${sampleOptions.theme}`}>
305326
<input value="Logout" type="button" onClick={() => {
306327
setIsLoggedin(false);
307-
store.current.setItem(STORAGE_KEY, JSON.stringify({
308-
login: false,
309-
currentAppId: sampleOptions.appId,
310-
apps: {
311-
...globalEnvironments?.apps,
312-
[sampleOptions.appId]: {
313-
currentUserId: sampleOptions.userId,
314-
users: {
315-
...globalEnvironments?.apps?.[sampleOptions.appId]?.users,
316-
[sampleOptions.userId]: sampleOptions,
317-
},
318-
},
319-
},
320-
}));
328+
storeCurrentSampleOptions({ store, sampleOptions, globalEnvironments });
321329
}} />
322330
<div style={{ height: 'calc(100% - 12px)' }}>
323331
{
@@ -341,6 +349,14 @@ export const GroupChannel = () => {
341349
replyType={sampleOptions.replyType}
342350
config={{ logLevel: 'all' }}
343351
breakpoint={/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)}
352+
onProfileEditSuccess={(user) => {
353+
const nextOptions = {
354+
...sampleOptions,
355+
nickname: user.nickname,
356+
};
357+
setSampleOptions(nextOptions);
358+
storeCurrentSampleOptions({ store, sampleOptions: nextOptions, globalEnvironments });
359+
}}
344360
stringSet={{
345361
// CHANNEL_SETTING__MODERATION__REGISTER_AS_OPERATOR: '오퍼레이터 등록',
346362
// CHANNEL_SETTING__MODERATION__UNREGISTER_OPERATOR: '오퍼레이터 해제',

src/modules/ChannelList/components/ChannelListUI/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
6060
typingChannels,
6161
initialized,
6262
fetchChannelList,
63+
onProfileEditSuccess,
6364
} = useChannelListContext();
6465

6566
const state = useSendbirdStateContext();
@@ -95,8 +96,9 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
9596
<EditUserProfile
9697
onThemeChange={onThemeChange}
9798
onCancel={() => { setShowProfileEdit(false); }}
98-
onEditProfile={() => {
99+
onEditProfile={(user: User) => {
99100
setShowProfileEdit(false);
101+
onProfileEditSuccess(user);
100102
}}
101103
/>
102104
)

src/modules/EditUserProfile/components/EditUserProfileUI/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import TextButton from '../../../../ui/TextButton';
2121
import { noop } from '../../../../utils/utils';
2222
import { USER_ACTIONS } from '../../../../lib/dux/user/actionTypes';
2323

24-
export default function EditUserProfile(): ReactElement {
24+
export default function EditUserProfileUI(): ReactElement {
2525
const editProfileProps = useEditUserProfileContext();
2626
const store = useSendbirdStateContext();
2727
const hiddenInputRef = useRef(null);

src/modules/EditUserProfile/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
EditUserProfileProps,
66
} from './context/EditUserProfileProvider';
77

8-
import EditUserProfile from './components/EditUserProfileUI';
8+
import EditUserProfileUI from './components/EditUserProfileUI';
99

10-
const EditProfile: React.FC<EditUserProfileProps> = (props: EditUserProfileProps) => {
10+
const EditUserProfile: React.FC<EditUserProfileProps> = (props: EditUserProfileProps) => {
1111
const {
1212
onEditProfile,
1313
onCancel,
@@ -19,9 +19,9 @@ const EditProfile: React.FC<EditUserProfileProps> = (props: EditUserProfileProps
1919
onCancel={onCancel}
2020
onThemeChange={onThemeChange}
2121
>
22-
<EditUserProfile />
22+
<EditUserProfileUI />
2323
</EditUserProfileProvider>
2424
);
2525
};
2626

27-
export default EditProfile;
27+
export default EditUserProfile;

0 commit comments

Comments
 (0)