Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/assets/mdi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
mdiCommentQuote,
mdiCommentTextMultipleOutline,
mdiContentCopy,
mdiCreation,
mdiCrown,
mdiDelete,
mdiDotsHorizontal,
Expand All @@ -50,7 +51,6 @@ import {
mdiFormatTitle,
mdiGithub,
mdiGoogle,
mdiHistory,
mdiHome,
mdiImageMultiple,
mdiInformation,
Expand Down Expand Up @@ -116,7 +116,6 @@ const mdi: MdiIconsMapping = {
'microphone-off': mdiMicrophoneOff,
pin: mdiPin,
search: mdiMagnify,
history: mdiHistory,
'file-upload': mdiFileUpload,
'file-music': mdiFileMusic,
'file-video': mdiFileVideo,
Expand Down Expand Up @@ -193,7 +192,8 @@ const mdi: MdiIconsMapping = {
'comment-outline': mdiCommentTextMultipleOutline,
'comment-off-outline': mdiCommentOffOutline,
'palette-outline': mdiPaletteOutline,
'content-copy': mdiContentCopy
'content-copy': mdiContentCopy,
creation: mdiCreation
}

export default mdi
6 changes: 3 additions & 3 deletions src/components/Main/MainView/MessageElement/MessageTools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import useToggle from '/@/composables/utils/useToggle'
import { isDefined } from '/@/lib/basic/array'
import { useStampUpdater } from '/@/lib/updater/stamp'
import { useMeStore } from '/@/store/domain/me'
import { useTopStampIds } from '/@/store/domain/stampRecommendations'
import { useStampRecommendations } from '/@/store/domain/stampRecommendations'
import { useMessagesStore } from '/@/store/entities/messages'
import { useStampsStore } from '/@/store/entities/stamps'
import { useMessageEditingStateStore } from '/@/store/ui/messageEditingStateStore'
Expand All @@ -120,7 +120,7 @@ const props = withDefaults(

const isActive = defineModel<boolean>('isActive', { default: false })

const { topStampIds } = useTopStampIds()
const { stampRecommendations } = useStampRecommendations()
const { addStampOptimistically } = useStampUpdater()
const { initialRecentStamps } = useStampsStore()

Expand All @@ -140,7 +140,7 @@ const pushInitialRecentStampsIfNeeded = (
}

const topStamps = computed(() => {
const tops = topStampIds.value.slice(0, 3)
const tops = stampRecommendations.value.slice(0, 3)
pushInitialRecentStampsIfNeeded(initialRecentStamps.value, tops)
return tops
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { type MaybeRefOrGetter, computed, toValue } from 'vue'

import type { Candidate, Word, WordWithId } from '/@/lib/suggestion/basic'
import { useStampHistory } from '/@/store/domain/stampHistory'
import { useStampRecommendations } from '/@/store/domain/stampRecommendations'

const stampSuggestionOverride = <
Expand All @@ -13,7 +12,6 @@ const stampSuggestionOverride = <
>(
input: Params
) => {
const { upsertLocalStampHistory } = useStampHistory()
const { recordStampUsage } = useStampRecommendations()

const isStampSuggestion = computed(() =>
Expand All @@ -30,7 +28,6 @@ const stampSuggestionOverride = <
})

const onSelect = (word: WordWithId) => {
upsertLocalStampHistory(word.id, new Date())
recordStampUsage(word.id)
input.onSelect({ ...word, text: `${word.text}:` })
}
Expand Down
7 changes: 2 additions & 5 deletions src/components/Main/StampPicker/StampPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import { onMounted, ref } from 'vue'
import ClickOutside from '/@/components/UI/ClickOutside'
import FilterInput from '/@/components/UI/FilterInput.vue'
import useResponsive from '/@/composables/useResponsive'
import { useStampHistory } from '/@/store/domain/stampHistory'
import { useStampRecommendations } from '/@/store/domain/stampRecommendations'
import { useStampPicker } from '/@/store/ui/stampPicker'
import type { StampId } from '/@/types/entity-ids'
Expand All @@ -72,10 +71,9 @@ const {
selectHandler,
isEffectEnabled,
currentStampSet,
validateCurrentStampSet,
ensureCurrentStampSetValid,
closeStampPicker
} = useStampPicker()
const { upsertLocalStampHistory } = useStampHistory()
const { isMobile } = useResponsive()

const animationKeys = ref(new Map<StampId, number>())
Expand All @@ -101,7 +99,6 @@ const { recordStampUsage } = useStampRecommendations()
const filterInputRef = ref<InstanceType<typeof FilterInput> | null>(null)

const onInputStamp = (id: StampId) => {
upsertLocalStampHistory(id, new Date())
recordStampUsage(id)
selectHandler.value({
id,
Expand All @@ -120,7 +117,7 @@ const onFilterEnter = () => {
onInputStamp(firstStamp.id)
}

onMounted(validateCurrentStampSet)
onMounted(ensureCurrentStampSetValid)
</script>

<style lang="scss" module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
:class="$style.icon"
/>
<AIcon
v-else-if="stampSet.type === 'history'"
v-else-if="stampSet.type === 'recommendation'"
mdi
name="history"
name="creation"
:size="24"
:class="$style.icon"
/>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Main/StampPicker/composables/useStampList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Ref } from 'vue'
import { computed } from 'vue'

import { useStampCategory } from '/@/store/domain/stampCategory'
import { useTopStampIds } from '/@/store/domain/stampRecommendations'
import { useStampRecommendations } from '/@/store/domain/stampRecommendations'
import { useStampPalettesStore } from '/@/store/entities/stampPalettes'
import { useStampsStore } from '/@/store/entities/stamps'
import type { StampId } from '/@/types/entity-ids'
Expand All @@ -12,13 +12,13 @@ import type { StampSet } from './useStampSetSelector'

const useStampList = (currentStampSet: Ref<StampSet>) => {
const { traQStampCategory, unicodeStampCategories } = useStampCategory()
const { topStampIds } = useTopStampIds()
const { stampRecommendations } = useStampRecommendations()
const { stampsMap } = useStampsStore()
const { stampPalettesMap } = useStampPalettesStore()

const stampIds = computed((): readonly StampId[] => {
if (currentStampSet.value.type === 'history') {
return topStampIds.value
if (currentStampSet.value.type === 'recommendation') {
return stampRecommendations.value
}
if (currentStampSet.value.type === 'palette') {
const id = currentStampSet.value.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { computed, reactive } from 'vue'
import { useStampCategory } from '/@/store/domain/stampCategory'
import { useStampPalettesStore } from '/@/store/entities/stampPalettes'

export type StampSetType = 'palette' | 'category' | 'history'
export type StampSetType = 'recommendation' | 'palette' | 'category'

export type StampSet = {
type: StampSetType
Expand All @@ -19,7 +19,7 @@ const useStampSetSelector = () => {
const state = reactive({
stampSets: computed((): StampSet[] => [
{
type: 'history',
type: 'recommendation',
id: ''
},
...state.stampPalettes,
Expand Down Expand Up @@ -47,7 +47,10 @@ const useStampSetSelector = () => {
hasStampPalette: computed((): boolean => state.stampPalettes.length > 0)
})

return { stampSetState: state }
const isStampSetValid = (stampSet: StampSet) =>
state.stampSets.some(s => s.type === stampSet.type && s.id === stampSet.id)

return { stampSetState: state, isStampSetValid }
}

export default useStampSetSelector
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ import { computed, onUnmounted, ref, watch } from 'vue'

import useStampFilter from '/@/components/Main/StampPicker/composables/useStampFilter'
import FilterInput from '/@/components/UI/FilterInput.vue'
import { useStampHistory } from '/@/store/domain/stampHistory'
import {
useStampRecommendations,
useTopStampIds
} from '/@/store/domain/stampRecommendations'
import { useStampRecommendations } from '/@/store/domain/stampRecommendations'
import { useStampsStore } from '/@/store/entities/stamps'
import type { StampId } from '/@/types/entity-ids'

Expand All @@ -62,14 +58,12 @@ const currentStampIds = defineModel<StampId[]>('current-stamp-ids', {
})

const { stampsMap, stampsMapFetched } = useStampsStore()
const { fetchStampHistory } = useStampHistory()
const { fetchStampRecommendations } = useStampRecommendations()
const { topStampIds } = useTopStampIds()
const { stampRecommendations, fetchStampRecommendations } =
useStampRecommendations()
const { filterState } = useStampFilter()

const displayCount = ref(ITEMS_PER_LOAD)

fetchStampHistory()
fetchStampRecommendations()
const allAddableStamps = computed(() => {
if (!stampsMapFetched.value) {
Expand All @@ -78,11 +72,11 @@ const allAddableStamps = computed(() => {
return (
filterState.query === ''
? [
...topStampIds.value
...stampRecommendations.value
.map(id => stampsMap.value.get(id))
.filter(stamp => stamp !== undefined),
...filterState.filteredItems
.filter(stamp => !topStampIds.value.includes(stamp.id))
.filter(stamp => !stampRecommendations.value.includes(stamp.id))
.sort((a, b) => a.name.localeCompare(b.name))
]
: filterState.filteredItems
Expand Down
3 changes: 0 additions & 3 deletions src/components/ShareTarget/ShareTargetMessageInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import MessageInputUploadButton from '/@/components/Main/MainView/MessageInput/M
import useMessageInputState from '/@/composables/messageInputState/useMessageInputState'
import useMessageInputStateAttachment from '/@/composables/messageInputState/useMessageInputStateAttachment'
import { randomString } from '/@/lib/basic/randomString'
import { useStampHistory } from '/@/store/domain/stampHistory'
import { useStampRecommendations } from '/@/store/domain/stampRecommendations'
import { useStampPalettesStore } from '/@/store/entities/stampPalettes'
import { useStampsStore } from '/@/store/entities/stamps'
Expand All @@ -52,7 +51,6 @@ import { useToastStore } from '/@/store/ui/toast'
import useAttachments from '../Main/MainView/MessageInput/composables/useAttachments'
import useTextStampPickerInvoker from '../Main/MainView/composables/useTextStampPickerInvoker'

const { fetchStampHistory } = useStampHistory()
const { fetchStampRecommendations } = useStampRecommendations()
const { fetchStamps } = useStampsStore()
const { fetchStampPalettes } = useStampPalettesStore()
Expand Down Expand Up @@ -82,7 +80,6 @@ const { toggleStampPicker } = useTextStampPickerInvoker(
// スタンプピッカーに必要
fetchStamps()
fetchStampPalettes()
fetchStampHistory()
fetchStampRecommendations()

const id = randomString()
Expand Down
3 changes: 0 additions & 3 deletions src/lib/updater/stamp.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import apis from '/@/lib/apis'
import { useStampHistory } from '/@/store/domain/stampHistory'
import { useStampRecommendations } from '/@/store/domain/stampRecommendations'
import { useMessagesStore } from '/@/store/entities/messages'
import { useToastStore } from '/@/store/ui/toast'
import type { MessageId, StampId } from '/@/types/entity-ids'

export const useStampUpdater = () => {
const { addErrorToast } = useToastStore()
const { upsertLocalStampHistory } = useStampHistory()
const { recordStampUsage } = useStampRecommendations()
const { addStampLocally, removeStampLocally } = useMessagesStore()

Expand All @@ -16,7 +14,6 @@ export const useStampUpdater = () => {
stampId: StampId
) => {
const cancel = addStampLocally(messageId, stampId)
upsertLocalStampHistory(stampId, new Date())
recordStampUsage(stampId)
try {
await apis.addMessageStamp(messageId, stampId)
Expand Down
52 changes: 0 additions & 52 deletions src/store/domain/stampHistory.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/store/domain/stampRecommendations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { computed, ref } from 'vue'
import { acceptHMRUpdate, defineStore } from 'pinia'

import apis from '/@/lib/apis'
import { useFeatureFlagSettings } from '/@/store/app/featureFlagSettings'
import { useStampHistory } from '/@/store/domain/stampHistory'
import { useStampsStore } from '/@/store/entities/stamps'
import { convertToRefsStore } from '/@/store/utils/convertToRefsStore'
import type { StampId } from '/@/types/entity-ids'
Expand Down Expand Up @@ -69,20 +67,6 @@ export const useStampRecommendations = convertToRefsStore(
useStampRecommendationsPinia
)

export const useTopStampIds = () => {
const { featureFlags } = useFeatureFlagSettings()
const { stampRecommendations } = useStampRecommendations()
const { recentStampIds } = useStampHistory()

const topStampIds = computed(() =>
featureFlags.value.stamp_recommendation.enabled
? stampRecommendations.value
: recentStampIds.value
)

return { topStampIds }
}

if (import.meta.hot) {
import.meta.hot.accept(
acceptHMRUpdate(useStampRecommendationsPinia, import.meta.hot)
Expand Down
Loading