pl-fe: tag history is not used
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -8,7 +8,6 @@ import { Language } from 'pl-fe/features/preferences';
|
|||||||
import { queryClient } from 'pl-fe/queries/client';
|
import { queryClient } from 'pl-fe/queries/client';
|
||||||
import { cancelDraftStatus } from 'pl-fe/queries/statuses/use-draft-statuses';
|
import { cancelDraftStatus } from 'pl-fe/queries/statuses/use-draft-statuses';
|
||||||
import { selectAccount, selectOwnAccount } from 'pl-fe/selectors';
|
import { selectAccount, selectOwnAccount } from 'pl-fe/selectors';
|
||||||
import { tagHistory } from 'pl-fe/settings';
|
|
||||||
import { useModalsStore } from 'pl-fe/stores/modals';
|
import { useModalsStore } from 'pl-fe/stores/modals';
|
||||||
import { useSettingsStore } from 'pl-fe/stores/settings';
|
import { useSettingsStore } from 'pl-fe/stores/settings';
|
||||||
import toast from 'pl-fe/toast';
|
import toast from 'pl-fe/toast';
|
||||||
@ -57,8 +56,6 @@ const COMPOSE_SUGGESTIONS_READY = 'COMPOSE_SUGGESTIONS_READY' as const;
|
|||||||
const COMPOSE_SUGGESTION_SELECT = 'COMPOSE_SUGGESTION_SELECT' as const;
|
const COMPOSE_SUGGESTION_SELECT = 'COMPOSE_SUGGESTION_SELECT' as const;
|
||||||
const COMPOSE_SUGGESTION_TAGS_UPDATE = 'COMPOSE_SUGGESTION_TAGS_UPDATE' as const;
|
const COMPOSE_SUGGESTION_TAGS_UPDATE = 'COMPOSE_SUGGESTION_TAGS_UPDATE' as const;
|
||||||
|
|
||||||
const COMPOSE_TAG_HISTORY_UPDATE = 'COMPOSE_TAG_HISTORY_UPDATE' as const;
|
|
||||||
|
|
||||||
const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE' as const;
|
const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE' as const;
|
||||||
const COMPOSE_TYPE_CHANGE = 'COMPOSE_TYPE_CHANGE' as const;
|
const COMPOSE_TYPE_CHANGE = 'COMPOSE_TYPE_CHANGE' as const;
|
||||||
const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE' as const;
|
const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE' as const;
|
||||||
@ -310,7 +307,6 @@ const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.scheduled_at === null) {
|
if (data.scheduled_at === null) {
|
||||||
dispatch(insertIntoTagHistory(composeId, data.tags || [], status));
|
|
||||||
toast.success(redact ? messages.redactSuccess : edit ? messages.editSuccess : messages.success, {
|
toast.success(redact ? messages.redactSuccess : edit ? messages.editSuccess : messages.success, {
|
||||||
actionLabel: messages.view,
|
actionLabel: messages.view,
|
||||||
actionLink: (data.visibility === 'direct' && getClient(getState()).features.conversations) ? '/conversations' : `/@${data.account.acct}/posts/${data.id}`,
|
actionLink: (data.visibility === 'direct' && getClient(getState()).features.conversations) ? '/conversations' : `/@${data.account.acct}/posts/${data.id}`,
|
||||||
@ -748,30 +744,6 @@ const updateSuggestionTags = (composeId: string, token: string, tags: Array<Tag>
|
|||||||
tags,
|
tags,
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateTagHistory = (composeId: string, tags: string[]) => ({
|
|
||||||
type: COMPOSE_TAG_HISTORY_UPDATE,
|
|
||||||
composeId,
|
|
||||||
tags,
|
|
||||||
});
|
|
||||||
|
|
||||||
const insertIntoTagHistory = (composeId: string, recognizedTags: Array<Tag>, text: string) =>
|
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
||||||
const state = getState();
|
|
||||||
const oldHistory = state.compose[composeId]!.tagHistory;
|
|
||||||
const me = state.me;
|
|
||||||
const names = recognizedTags
|
|
||||||
.filter(tag => text.match(new RegExp(`#${tag.name}`, 'i')))
|
|
||||||
.map(tag => tag.name);
|
|
||||||
const intersectedOldHistory = oldHistory.filter(name => names.findIndex(newName => newName.toLowerCase() === name.toLowerCase()) === -1);
|
|
||||||
|
|
||||||
names.push(...intersectedOldHistory);
|
|
||||||
|
|
||||||
const newHistory = names.slice(0, 1000);
|
|
||||||
|
|
||||||
tagHistory.set(me as string, newHistory);
|
|
||||||
dispatch(updateTagHistory(composeId, newHistory));
|
|
||||||
};
|
|
||||||
|
|
||||||
const changeComposeSpoilerness = (composeId: string) => ({
|
const changeComposeSpoilerness = (composeId: string) => ({
|
||||||
type: COMPOSE_SPOILERNESS_CHANGE,
|
type: COMPOSE_SPOILERNESS_CHANGE,
|
||||||
composeId,
|
composeId,
|
||||||
@ -1036,7 +1008,6 @@ type ComposeAction =
|
|||||||
| ComposeSuggestionsReadyAction
|
| ComposeSuggestionsReadyAction
|
||||||
| ComposeSuggestionSelectAction
|
| ComposeSuggestionSelectAction
|
||||||
| ReturnType<typeof updateSuggestionTags>
|
| ReturnType<typeof updateSuggestionTags>
|
||||||
| ReturnType<typeof updateTagHistory>
|
|
||||||
| ReturnType<typeof changeComposeSpoilerness>
|
| ReturnType<typeof changeComposeSpoilerness>
|
||||||
| ReturnType<typeof changeComposeContentType>
|
| ReturnType<typeof changeComposeContentType>
|
||||||
| ReturnType<typeof changeComposeSpoilerText>
|
| ReturnType<typeof changeComposeSpoilerText>
|
||||||
@ -1094,7 +1065,6 @@ export {
|
|||||||
COMPOSE_SUGGESTIONS_READY,
|
COMPOSE_SUGGESTIONS_READY,
|
||||||
COMPOSE_SUGGESTION_SELECT,
|
COMPOSE_SUGGESTION_SELECT,
|
||||||
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
||||||
COMPOSE_TAG_HISTORY_UPDATE,
|
|
||||||
COMPOSE_SPOILERNESS_CHANGE,
|
COMPOSE_SPOILERNESS_CHANGE,
|
||||||
COMPOSE_TYPE_CHANGE,
|
COMPOSE_TYPE_CHANGE,
|
||||||
COMPOSE_SPOILER_TEXT_CHANGE,
|
COMPOSE_SPOILER_TEXT_CHANGE,
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { create } from 'mutative';
|
import { create } from 'mutative';
|
||||||
|
|
||||||
import { INSTANCE_FETCH_SUCCESS, type InstanceAction } from 'pl-fe/actions/instance';
|
import { INSTANCE_FETCH_SUCCESS, type InstanceAction } from 'pl-fe/actions/instance';
|
||||||
import { tagHistory } from 'pl-fe/settings';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
COMPOSE_CHANGE,
|
COMPOSE_CHANGE,
|
||||||
@ -24,7 +23,6 @@ import {
|
|||||||
COMPOSE_SUGGESTIONS_READY,
|
COMPOSE_SUGGESTIONS_READY,
|
||||||
COMPOSE_SUGGESTION_SELECT,
|
COMPOSE_SUGGESTION_SELECT,
|
||||||
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
||||||
COMPOSE_TAG_HISTORY_UPDATE,
|
|
||||||
COMPOSE_SPOILERNESS_CHANGE,
|
COMPOSE_SPOILERNESS_CHANGE,
|
||||||
COMPOSE_TYPE_CHANGE,
|
COMPOSE_TYPE_CHANGE,
|
||||||
COMPOSE_SPOILER_TEXT_CHANGE,
|
COMPOSE_SPOILER_TEXT_CHANGE,
|
||||||
@ -151,7 +149,6 @@ interface Compose {
|
|||||||
approvalRequired: boolean;
|
approvalRequired: boolean;
|
||||||
suggestedLanguage: string | null;
|
suggestedLanguage: string | null;
|
||||||
suggestions: Array<string> | Array<Emoji>;
|
suggestions: Array<string> | Array<Emoji>;
|
||||||
tagHistory: Array<string>;
|
|
||||||
dismissedClearLinksSuggestions: Array<string>;
|
dismissedClearLinksSuggestions: Array<string>;
|
||||||
clearLinkSuggestion: ClearLinkSuggestion | null;
|
clearLinkSuggestion: ClearLinkSuggestion | null;
|
||||||
preview: Partial<BaseStatus> | null;
|
preview: Partial<BaseStatus> | null;
|
||||||
@ -188,7 +185,6 @@ const newCompose = (params: Partial<Compose> = {}): Compose => ({
|
|||||||
spoilerText: '',
|
spoilerText: '',
|
||||||
spoilerTextMap: {},
|
spoilerTextMap: {},
|
||||||
suggestions: [],
|
suggestions: [],
|
||||||
tagHistory: [],
|
|
||||||
text: '',
|
text: '',
|
||||||
textMap: {},
|
textMap: {},
|
||||||
to: [],
|
to: [],
|
||||||
@ -321,7 +317,6 @@ const importAccount = (compose: Compose, account: CredentialAccount) => {
|
|||||||
|
|
||||||
if (settings.defaultPrivacy) compose.visibility = settings.defaultPrivacy;
|
if (settings.defaultPrivacy) compose.visibility = settings.defaultPrivacy;
|
||||||
if (settings.defaultContentType) compose.contentType = settings.defaultContentType;
|
if (settings.defaultContentType) compose.contentType = settings.defaultContentType;
|
||||||
compose.tagHistory = tagHistory.get(account.id) || [];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// const updateSetting = (compose: Compose, path: string[], value: string) => {
|
// const updateSetting = (compose: Compose, path: string[], value: string) => {
|
||||||
@ -528,10 +523,6 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | In
|
|||||||
return updateCompose(state, action.composeId, compose => insertSuggestion(compose, action.position, action.token, action.completion, action.path));
|
return updateCompose(state, action.composeId, compose => insertSuggestion(compose, action.position, action.token, action.completion, action.path));
|
||||||
case COMPOSE_SUGGESTION_TAGS_UPDATE:
|
case COMPOSE_SUGGESTION_TAGS_UPDATE:
|
||||||
return updateCompose(state, action.composeId, compose => updateSuggestionTags(compose, action.token, action.tags));
|
return updateCompose(state, action.composeId, compose => updateSuggestionTags(compose, action.token, action.tags));
|
||||||
case COMPOSE_TAG_HISTORY_UPDATE:
|
|
||||||
return updateCompose(state, action.composeId, compose => {
|
|
||||||
compose.tagHistory = action.tags;
|
|
||||||
});
|
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
return updateCompose(state, 'compose-modal', compose => {
|
return updateCompose(state, 'compose-modal', compose => {
|
||||||
if (action.statusId === compose.inReplyToId) {
|
if (action.statusId === compose.inReplyToId) {
|
||||||
|
|||||||
@ -49,10 +49,6 @@ class Settings {
|
|||||||
/** Remember push notification settings. */
|
/** Remember push notification settings. */
|
||||||
const pushNotificationsSetting = new Settings('plfe_push_notification_data');
|
const pushNotificationsSetting = new Settings('plfe_push_notification_data');
|
||||||
|
|
||||||
/** Remember hashtag usage. */
|
|
||||||
const tagHistory = new Settings('plfe_tag_history');
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
pushNotificationsSetting,
|
pushNotificationsSetting,
|
||||||
tagHistory,
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user