forked from glitch-soc/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add emoji overlay to avatars in reaction list
I swear there has to be a better way to do this
- Loading branch information
Showing
9 changed files
with
138 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface ApiStatusReactionJSON { | ||
name: string; | ||
static_url?: string | undefined; | ||
url?: string | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { RecordOf } from 'immutable'; | ||
import { Record } from 'immutable'; | ||
|
||
import type { ApiStatusReactionJSON } from 'flavours/glitch/api_types/reaction'; | ||
|
||
type StatusReactionShape = Required<ApiStatusReactionJSON>; | ||
export type StatusReaction = RecordOf<StatusReactionShape>; | ||
|
||
export const CustomEmojiFactory = Record<StatusReactionShape>({ | ||
name: '', | ||
static_url: '', | ||
url: '', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/javascript/flavours/glitch/reducers/status_reactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable'; | ||
|
||
import { | ||
REACTIONS_FETCH_SUCCESS, | ||
REACTIONS_EXPAND_SUCCESS, | ||
REACTIONS_FETCH_REQUEST, | ||
REACTIONS_EXPAND_REQUEST, | ||
REACTIONS_FETCH_FAIL, | ||
REACTIONS_EXPAND_FAIL, | ||
} from '../actions/interactions'; | ||
|
||
const initialState = ImmutableMap({ | ||
reactions: ImmutableMap({ | ||
next: null, | ||
isLoading: false, | ||
items: ImmutableOrderedSet(), | ||
}), | ||
}); | ||
|
||
const normalizeList = (state, path, reactions, next) => { | ||
const filteredReactions = reactions.map(v => { | ||
v.account = v.account.id; | ||
return v; | ||
}); | ||
return state.setIn(path, ImmutableMap({ | ||
next, | ||
items: ImmutableOrderedSet(filteredReactions), | ||
isLoading: false, | ||
})); | ||
}; | ||
|
||
const appendToList = (state, path, reactions, next) => { | ||
const filteredReactions = reactions.map(v => { | ||
v.account = v.account.id; | ||
return v; | ||
}); | ||
return state.updateIn(path, map => { | ||
return map.set('next', next).set('isLoading', false).update('items', list => list.concat(filteredReactions)); | ||
}); | ||
}; | ||
|
||
export default function statusReactions(state = initialState, action) { | ||
switch(action.type) { | ||
case REACTIONS_FETCH_SUCCESS: | ||
return normalizeList(state, ['reactions', action.id], action.reactions, action.next); | ||
case REACTIONS_EXPAND_SUCCESS: | ||
return appendToList(state, ['reactions', action.id], action.reactions, action.next); | ||
case REACTIONS_FETCH_REQUEST: | ||
case REACTIONS_EXPAND_REQUEST: | ||
return state.setIn(['reactions', action.id, 'isLoading'], true); | ||
case REACTIONS_FETCH_FAIL: | ||
case REACTIONS_EXPAND_FAIL: | ||
return state.setIn(['reactions', action.id, 'isLoading'], false); | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters