Show/remove share link if turning off Make Public
This commit is contained in:
parent
47964bcd53
commit
f545f5c786
|
@ -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 { removeTags, cloneObject, getTimestampInSeconds, download, slugify } from "../helpers";
|
||||||
import { LOCAL_STORAGE_KEY, DEFAULT_DICTIONARY, MIGRATE_VERSION } from "../constants";
|
import { LOCAL_STORAGE_KEY, DEFAULT_DICTIONARY, MIGRATE_VERSION } from "../constants";
|
||||||
import { addMessage, getNextId, hasToken } from "./utilities";
|
import { addMessage, getNextId, hasToken } from "./utilities";
|
||||||
|
@ -63,7 +63,10 @@ export function saveEditModal() {
|
||||||
window.currentDictionary.settings.caseSensitive = document.getElementById('editCaseSensitive').checked;
|
window.currentDictionary.settings.caseSensitive = document.getElementById('editCaseSensitive').checked;
|
||||||
const needsReSort = window.currentDictionary.settings.sortByDefinition !== document.getElementById('editSortByDefinition').checked;
|
const needsReSort = window.currentDictionary.settings.sortByDefinition !== document.getElementById('editSortByDefinition').checked;
|
||||||
window.currentDictionary.settings.sortByDefinition = document.getElementById('editSortByDefinition').checked;
|
window.currentDictionary.settings.sortByDefinition = document.getElementById('editSortByDefinition').checked;
|
||||||
|
|
||||||
|
let needsWordRender = false;
|
||||||
if (hasToken()) {
|
if (hasToken()) {
|
||||||
|
needsWordRender = window.currentDictionary.settings.isPublic !== document.getElementById('editIsPublic').checked;
|
||||||
window.currentDictionary.settings.isPublic = document.getElementById('editIsPublic').checked;
|
window.currentDictionary.settings.isPublic = document.getElementById('editIsPublic').checked;
|
||||||
} else {
|
} else {
|
||||||
window.currentDictionary.settings.isPublic = false;
|
window.currentDictionary.settings.isPublic = false;
|
||||||
|
@ -73,8 +76,8 @@ export function saveEditModal() {
|
||||||
saveDictionary();
|
saveDictionary();
|
||||||
renderDictionaryDetails();
|
renderDictionaryDetails();
|
||||||
renderPartsOfSpeech();
|
renderPartsOfSpeech();
|
||||||
|
|
||||||
if (needsReSort) {
|
if (needsReSort || needsWordRender) {
|
||||||
sortWords(true);
|
sortWords(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,9 @@ export function renderName() {
|
||||||
const name = document.getElementById('dictionaryName');
|
const name = document.getElementById('dictionaryName');
|
||||||
name.innerHTML = dictionaryName;
|
name.innerHTML = dictionaryName;
|
||||||
const isPublic = hasToken() && window.currentDictionary.settings.isPublic;
|
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');
|
const shareLink = document.createElement('a');
|
||||||
shareLink.id = 'dictionaryShare';
|
shareLink.id = 'dictionaryShare';
|
||||||
shareLink.classList.add('button');
|
shareLink.classList.add('button');
|
||||||
|
@ -50,6 +52,8 @@ export function renderName() {
|
||||||
shareLink.title = 'Public Link to Dictionary';
|
shareLink.title = 'Public Link to Dictionary';
|
||||||
shareLink.innerHTML = '➦';
|
shareLink.innerHTML = '➦';
|
||||||
name.parentElement.insertBefore(shareLink, name);
|
name.parentElement.insertBefore(shareLink, name);
|
||||||
|
} else if (!isPublic && shareLinkElement) {
|
||||||
|
shareLinkElement.parentElement.removeChild(shareLinkElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue