diff --git a/routes/_actions/emoji.js b/routes/_actions/emoji.js index 89da860..2ced1a9 100644 --- a/routes/_actions/emoji.js +++ b/routes/_actions/emoji.js @@ -17,13 +17,11 @@ export async function updateCustomEmojiForInstance (instanceName) { ) } -export function insertEmoji (emoji) { +export function insertEmoji (realm, emoji) { let idx = store.get('composeSelectionStart') || 0 - let oldText = store.get('rawComposeText') || '' + let oldText = store.getComposeData(realm, 'text') let pre = oldText ? substring(oldText, 0, idx) : '' let post = oldText ? substring(oldText, idx) : '' let newText = `${pre}:${emoji.shortcode}: ${post}` - store.set({ - rawComposeText: newText - }) + store.setComposeData(realm, {text: newText}) } diff --git a/routes/_actions/instances.js b/routes/_actions/instances.js index 76eebf5..30574a8 100644 --- a/routes/_actions/instances.js +++ b/routes/_actions/instances.js @@ -22,8 +22,7 @@ export function switchToInstance (instanceName) { store.set({ currentInstance: instanceName, searchResults: null, - queryInSearch: '', - rawComposeText: '' + queryInSearch: '' }) store.save() switchToTheme(instanceThemes[instanceName]) @@ -49,7 +48,6 @@ export async function logOutOfInstance (instanceName) { currentInstance: newInstance, searchResults: null, queryInSearch: '', - rawComposeText: '', composeData: composeData }) store.save() diff --git a/routes/_actions/media.js b/routes/_actions/media.js index 4068d42..14bc322 100644 --- a/routes/_actions/media.js +++ b/routes/_actions/media.js @@ -14,10 +14,12 @@ export async function doMediaUpload (realm, file) { data: response, file: { name: file.name } }) - let rawComposeText = store.get('rawComposeText') || '' - rawComposeText += ' ' + response.text_url - store.setComposeData(realm, 'media', composeMedia) - store.set({rawComposeText}) + let composeText = store.getComposeData(realm, 'text') || '' + composeText += ' ' + response.text_url + store.setComposeData(realm, { + media: composeMedia, + text: composeText + }) scheduleIdleTask(() => store.save()) } catch (e) { console.error(e) @@ -31,11 +33,12 @@ export function deleteMedia (realm, i) { let composeMedia = store.getComposeData(realm, 'media') let deletedMedia = composeMedia.splice(i, 1)[0] - let rawComposeText = store.get('rawComposeText') || '' + let composeText = store.getComposeData(realm, 'text') || '' + composeText = composeText.replace(' ' + deletedMedia.data.text_url, '') - rawComposeText = rawComposeText.replace(' ' + deletedMedia.data.text_url, '') - - store.setComposeData(realm, 'media', composeMedia) - store.set({rawComposeText}) + store.setComposeData(realm, { + media: composeMedia, + text: composeText + }) scheduleIdleTask(() => store.save()) } diff --git a/routes/_actions/postPrivacy.js b/routes/_actions/postPrivacy.js index 753b226..054bea6 100644 --- a/routes/_actions/postPrivacy.js +++ b/routes/_actions/postPrivacy.js @@ -2,5 +2,5 @@ import { store } from '../_store/store' export function setPostPrivacy (realm, postPrivacyKey) { - store.setComposeData(realm, 'postPrivacy', postPrivacyKey) + store.setComposeData(realm, {postPrivacy: postPrivacyKey}) } diff --git a/routes/_components/compose/ComposeBox.html b/routes/_components/compose/ComposeBox.html index da45ecf..3b6825c 100644 --- a/routes/_components/compose/ComposeBox.html +++ b/routes/_components/compose/ComposeBox.html @@ -1,11 +1,11 @@