mirror of
				https://github.com/Alamantus/Lexiconga.git
				synced 2025-11-04 10:17:01 +01:00 
			
		
		
		
	Show/remove share link if turning off Make Public
This commit is contained in:
		
							parent
							
								
									596efff70d
								
							
						
					
					
						commit
						db021647bd
					
				
					 2 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import { renderDictionaryDetails, renderPartsOfSpeech, renderAll } from "./render";
 | 
			
		||||
import { renderDictionaryDetails, renderPartsOfSpeech, renderAll, renderWords } from "./render";
 | 
			
		||||
import { removeTags, cloneObject, getTimestampInSeconds, download, slugify } from "../helpers";
 | 
			
		||||
import { LOCAL_STORAGE_KEY, DEFAULT_DICTIONARY, MIGRATE_VERSION } from "../constants";
 | 
			
		||||
import { addMessage, getNextId, hasToken } from "./utilities";
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,10 @@ export function saveEditModal() {
 | 
			
		|||
  window.currentDictionary.settings.caseSensitive = document.getElementById('editCaseSensitive').checked;
 | 
			
		||||
  const needsReSort = window.currentDictionary.settings.sortByDefinition !== document.getElementById('editSortByDefinition').checked;
 | 
			
		||||
  window.currentDictionary.settings.sortByDefinition = document.getElementById('editSortByDefinition').checked;
 | 
			
		||||
 | 
			
		||||
  let needsWordRender = false;
 | 
			
		||||
  if (hasToken()) {
 | 
			
		||||
    needsWordRender = window.currentDictionary.settings.isPublic !== document.getElementById('editIsPublic').checked;
 | 
			
		||||
    window.currentDictionary.settings.isPublic = document.getElementById('editIsPublic').checked;
 | 
			
		||||
  } else {
 | 
			
		||||
    window.currentDictionary.settings.isPublic = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -73,8 +76,8 @@ export function saveEditModal() {
 | 
			
		|||
  saveDictionary();
 | 
			
		||||
  renderDictionaryDetails();
 | 
			
		||||
  renderPartsOfSpeech();
 | 
			
		||||
 | 
			
		||||
  if (needsReSort) {
 | 
			
		||||
  
 | 
			
		||||
  if (needsReSort || needsWordRender) {
 | 
			
		||||
    sortWords(true);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,9 @@ export function renderName() {
 | 
			
		|||
  const name = document.getElementById('dictionaryName');
 | 
			
		||||
  name.innerHTML = dictionaryName;
 | 
			
		||||
  const isPublic = hasToken() && window.currentDictionary.settings.isPublic;
 | 
			
		||||
  if (isPublic && !document.getElementById('dictionaryShare')) {
 | 
			
		||||
  const shareLinkElement = document.getElementById('dictionaryShare');
 | 
			
		||||
 | 
			
		||||
  if (isPublic && !shareLinkElement) {
 | 
			
		||||
    const shareLink = document.createElement('a');
 | 
			
		||||
    shareLink.id = 'dictionaryShare';
 | 
			
		||||
    shareLink.classList.add('button');
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +52,8 @@ export function renderName() {
 | 
			
		|||
    shareLink.title = 'Public Link to Dictionary';
 | 
			
		||||
    shareLink.innerHTML = '➦';
 | 
			
		||||
    name.parentElement.insertBefore(shareLink, name);
 | 
			
		||||
  } else if (!isPublic && shareLinkElement) {
 | 
			
		||||
    shareLinkElement.parentElement.removeChild(shareLinkElement);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue