fix(frontend): use new but unsaved custom preferences on edit profile page
This commit is contained in:
		
							parent
							
								
									bd279a7dae
								
							
						
					
					
						commit
						1dc4089cef
					
				
					 3 changed files with 11 additions and 26 deletions
				
			
		|  | @ -67,15 +67,6 @@ export interface Pronoun { | |||
|   status: string; | ||||
| } | ||||
| 
 | ||||
| export enum WordStatus { | ||||
|   Unknown = "", | ||||
|   Favourite = "favourite", | ||||
|   Okay = "okay", | ||||
|   Jokingly = "jokingly", | ||||
|   FriendsOnly = "friends_only", | ||||
|   Avoid = "avoid", | ||||
| } | ||||
| 
 | ||||
| export interface PartialMember { | ||||
|   id: string; | ||||
|   name: string; | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
|   import { | ||||
|     MAX_DESCRIPTION_LENGTH, | ||||
|     memberAvatars, | ||||
|     WordStatus, | ||||
|     type APIError, | ||||
|     type Field, | ||||
|     type FieldEntry, | ||||
|  | @ -204,7 +203,7 @@ | |||
|   const addName = (event: Event) => { | ||||
|     event.preventDefault(); | ||||
| 
 | ||||
|     names = [...names, { value: newName, status: WordStatus.Okay }]; | ||||
|     names = [...names, { value: newName, status: "okay" }]; | ||||
|     newName = ""; | ||||
|   }; | ||||
| 
 | ||||
|  | @ -218,14 +217,11 @@ | |||
|         { | ||||
|           pronouns: fullSet.pronouns.join("/"), | ||||
|           display_text: fullSet.display || null, | ||||
|           status: WordStatus.Okay, | ||||
|           status: "okay", | ||||
|         }, | ||||
|       ]; | ||||
|     } else { | ||||
|       pronouns = [ | ||||
|         ...pronouns, | ||||
|         { pronouns: newPronouns, display_text: null, status: WordStatus.Okay }, | ||||
|       ]; | ||||
|       pronouns = [...pronouns, { pronouns: newPronouns, display_text: null, status: "okay" }]; | ||||
|     } | ||||
|     newPronouns = ""; | ||||
|   }; | ||||
|  | @ -309,7 +305,7 @@ | |||
|   $: deleteModalPronoun = updateModalPronoun(pronouns); | ||||
| 
 | ||||
|   const updateModalPronoun = (pronouns: Pronoun[]) => { | ||||
|     const filtered = pronouns.filter((entry) => entry.status === WordStatus.Favourite); | ||||
|     const filtered = pronouns.filter((entry) => entry.status === "favourite"); | ||||
|     if (filtered.length < 1) return "the member's"; | ||||
| 
 | ||||
|     const split = filtered[0].pronouns.split("/"); | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   import { | ||||
|     MAX_DESCRIPTION_LENGTH, | ||||
|     userAvatars, | ||||
|     WordStatus, | ||||
|     type APIError, | ||||
|     type Field, | ||||
|     type FieldEntry, | ||||
|  | @ -218,7 +217,7 @@ | |||
|   const addName = (event: Event) => { | ||||
|     event.preventDefault(); | ||||
| 
 | ||||
|     names = [...names, { value: newName, status: WordStatus.Okay }]; | ||||
|     names = [...names, { value: newName, status: "okay" }]; | ||||
|     newName = ""; | ||||
|   }; | ||||
| 
 | ||||
|  | @ -232,14 +231,11 @@ | |||
|         { | ||||
|           pronouns: fullSet.pronouns.join("/"), | ||||
|           display_text: fullSet.display || null, | ||||
|           status: WordStatus.Okay, | ||||
|           status: "okay", | ||||
|         }, | ||||
|       ]; | ||||
|     } else { | ||||
|       pronouns = [ | ||||
|         ...pronouns, | ||||
|         { pronouns: newPronouns, display_text: null, status: WordStatus.Okay }, | ||||
|       ]; | ||||
|       pronouns = [...pronouns, { pronouns: newPronouns, display_text: null, status: "okay" }]; | ||||
|     } | ||||
|     newPronouns = ""; | ||||
|   }; | ||||
|  | @ -311,6 +307,7 @@ | |||
|       }); | ||||
| 
 | ||||
|       data.user = resp; | ||||
|       custom_preferences = resp.custom_preferences; | ||||
|       userStore.set(resp); | ||||
|       localStorage.setItem("pronouns-user", JSON.stringify(resp)); | ||||
| 
 | ||||
|  | @ -411,7 +408,7 @@ | |||
|         <EditableName | ||||
|           bind:value={names[index].value} | ||||
|           bind:status={names[index].status} | ||||
|           preferences={data.user.custom_preferences} | ||||
|           preferences={custom_preferences} | ||||
|           moveUp={() => moveName(index, true)} | ||||
|           moveDown={() => moveName(index, false)} | ||||
|           remove={() => removeName(index)} | ||||
|  | @ -451,6 +448,7 @@ | |||
|         {#each pronouns as _, index} | ||||
|           <EditablePronouns | ||||
|             bind:pronoun={pronouns[index]} | ||||
|             preferences={custom_preferences} | ||||
|             moveUp={() => movePronoun(index, true)} | ||||
|             moveDown={() => movePronoun(index, false)} | ||||
|             remove={() => removePronoun(index)} | ||||
|  | @ -492,7 +490,7 @@ | |||
|         {#each fields as _, index} | ||||
|           <EditableField | ||||
|             bind:field={fields[index]} | ||||
|             preferences={data.user.custom_preferences} | ||||
|             preferences={custom_preferences} | ||||
|             deleteField={() => removeField(index)} | ||||
|             moveField={(up) => moveField(index, up)} | ||||
|           /> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue