Display name sync
This commit is contained in:
		
							parent
							
								
									7ae8049438
								
							
						
					
					
						commit
						2fb4bd4975
					
				
					 12 changed files with 897 additions and 793 deletions
				
			
		|  | @ -204,7 +204,7 @@ const SettingsIcons = (props) => { | |||
| 
 | ||||
|     return ( | ||||
|         <> | ||||
|             <IconButton color="inherit" size="large" edge="end" onClick={handleToggleMute} sx={{marginRight: 0}} aria-label={t("action_bar_toggle_mute")}> | ||||
|             <IconButton color="inherit" size="large" edge="end" onClick={handleToggleMute} aria-label={t("action_bar_toggle_mute")}> | ||||
|                 {subscription.mutedUntil ? <NotificationsOffIcon/> : <NotificationsIcon/>} | ||||
|             </IconButton> | ||||
|             <IconButton color="inherit" size="large" edge="end" ref={anchorRef} onClick={handleToggleOpen} aria-label={t("action_bar_toggle_action_menu")}> | ||||
|  |  | |||
|  | @ -319,42 +319,52 @@ const UserTable = (props) => { | |||
|         } | ||||
|     }; | ||||
|     return ( | ||||
|         <Table size="small" aria-label={t("prefs_users_table")}> | ||||
|             <TableHead> | ||||
|                 <TableRow> | ||||
|                     <TableCell sx={{paddingLeft: 0}}>{t("prefs_users_table_user_header")}</TableCell> | ||||
|                     <TableCell>{t("prefs_users_table_base_url_header")}</TableCell> | ||||
|                     <TableCell/> | ||||
|                 </TableRow> | ||||
|             </TableHead> | ||||
|             <TableBody> | ||||
|                 {props.users?.map(user => ( | ||||
|                     <TableRow | ||||
|                         key={user.baseUrl} | ||||
|                         sx={{ '&:last-child td, &:last-child th': { border: 0 } }} | ||||
|                     > | ||||
|                         <TableCell component="th" scope="row" sx={{paddingLeft: 0}} aria-label={t("prefs_users_table_user_header")}>{user.username}</TableCell> | ||||
|                         <TableCell aria-label={t("prefs_users_table_base_url_header")}>{user.baseUrl}</TableCell> | ||||
|                         <TableCell align="right"> | ||||
|                             <IconButton onClick={() => handleEditClick(user)} aria-label={t("prefs_users_edit_button")}> | ||||
|                                 <EditIcon/> | ||||
|                             </IconButton> | ||||
|                             <IconButton onClick={() => handleDeleteClick(user)} aria-label={t("prefs_users_delete_button")}> | ||||
|                                 <CloseIcon /> | ||||
|                             </IconButton> | ||||
|                         </TableCell> | ||||
|         <div> | ||||
|             <Table size="small" aria-label={t("prefs_users_table")}> | ||||
|                 <TableHead> | ||||
|                     <TableRow> | ||||
|                         <TableCell sx={{paddingLeft: 0}}>{t("prefs_users_table_user_header")}</TableCell> | ||||
|                         <TableCell>{t("prefs_users_table_base_url_header")}</TableCell> | ||||
|                         <TableCell/> | ||||
|                     </TableRow> | ||||
|                 ))} | ||||
|             </TableBody> | ||||
|             <UserDialog | ||||
|                 key={`userEditDialog${dialogKey}`} | ||||
|                 open={dialogOpen} | ||||
|                 user={dialogUser} | ||||
|                 users={props.users} | ||||
|                 onCancel={handleDialogCancel} | ||||
|                 onSubmit={handleDialogSubmit} | ||||
|             /> | ||||
|         </Table> | ||||
|                 </TableHead> | ||||
|                 <TableBody> | ||||
|                     {props.users?.map(user => ( | ||||
|                         <TableRow | ||||
|                             key={user.baseUrl} | ||||
|                             sx={{'&:last-child td, &:last-child th': {border: 0}}} | ||||
|                         > | ||||
|                             <TableCell component="th" scope="row" sx={{paddingLeft: 0}} | ||||
|                                        aria-label={t("prefs_users_table_user_header")}>{user.username}</TableCell> | ||||
|                             <TableCell aria-label={t("prefs_users_table_base_url_header")}>{user.baseUrl}</TableCell> | ||||
|                             <TableCell align="right"> | ||||
|                                 <IconButton onClick={() => handleEditClick(user)} | ||||
|                                             aria-label={t("prefs_users_edit_button")}> | ||||
|                                     <EditIcon/> | ||||
|                                 </IconButton> | ||||
|                                 <IconButton onClick={() => handleDeleteClick(user)} | ||||
|                                             aria-label={t("prefs_users_delete_button")}> | ||||
|                                     <CloseIcon/> | ||||
|                                 </IconButton> | ||||
|                             </TableCell> | ||||
|                         </TableRow> | ||||
|                     ))} | ||||
|                 </TableBody> | ||||
|                 <UserDialog | ||||
|                     key={`userEditDialog${dialogKey}`} | ||||
|                     open={dialogOpen} | ||||
|                     user={dialogUser} | ||||
|                     users={props.users} | ||||
|                     onCancel={handleDialogCancel} | ||||
|                     onSubmit={handleDialogSubmit} | ||||
|                 /> | ||||
|             </Table> | ||||
|             {session.exists() && | ||||
|                 <Typography> | ||||
|                     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||||
|                 </Typography> | ||||
|             } | ||||
|         </div> | ||||
|     ); | ||||
| }; | ||||
| 
 | ||||
|  | @ -672,8 +682,7 @@ const maybeUpdateAccountSettings = async (payload) => { | |||
|     } catch (e) { | ||||
|         console.log(`[Preferences] Error updating account settings`, e); | ||||
|         if ((e instanceof UnauthorizedError)) { | ||||
|             session.reset(); | ||||
|             window.location.href = routes.login; | ||||
|             session.resetAndRedirect(routes.login); | ||||
|         } | ||||
|     } | ||||
| }; | ||||
|  |  | |||
|  | @ -15,6 +15,9 @@ import subscriptionManager from "../app/SubscriptionManager"; | |||
| import poller from "../app/Poller"; | ||||
| import DialogFooter from "./DialogFooter"; | ||||
| import {useTranslation} from "react-i18next"; | ||||
| import accountApi, {UnauthorizedError} from "../app/AccountApi"; | ||||
| import session from "../app/Session"; | ||||
| import routes from "./routes"; | ||||
| 
 | ||||
| const SubscriptionSettingsDialog = (props) => { | ||||
|     const { t } = useTranslation(); | ||||
|  | @ -23,6 +26,17 @@ const SubscriptionSettingsDialog = (props) => { | |||
|     const fullScreen = useMediaQuery(theme.breakpoints.down('sm')); | ||||
|     const handleSave = async () => { | ||||
|         await subscriptionManager.setDisplayName(subscription.id, displayName); | ||||
|         if (session.exists() && subscription.remoteId) { | ||||
|             try { | ||||
|                 console.log(`[SubscriptionSettingsDialog] Updating subscription display name to ${displayName}`); | ||||
|                 await accountApi.updateSubscription(subscription.remoteId, { display_name: displayName }); | ||||
|             } catch (e) { | ||||
|                 console.log(`[SubscriptionSettingsDialog] Error updating subscription`, e); | ||||
|                 if ((e instanceof UnauthorizedError)) { | ||||
|                     session.resetAndRedirect(routes.login); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         props.onClose(); | ||||
|     } | ||||
|     return ( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue