-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from AJ-Quran/71-overloading-avatar
Overloading Avatar
- Loading branch information
Showing
3 changed files
with
23 additions
and
14 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
16 changes: 2 additions & 14 deletions
16
src/pages/Main/components/Account/components/utils/Avatar.jsx
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
18 changes: 18 additions & 0 deletions
18
src/pages/Main/components/Account/components/utils/getAvatar.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,18 @@ | ||
import { load } from '../../../../../../js/db/db' | ||
import { loadLocal } from '../../../../../../js/db/localStorage' | ||
|
||
const avatars = new Map() | ||
export { avatars } | ||
|
||
export async function getAvatar(username) { | ||
username = username ? username : loadLocal('quran').accounts.active | ||
if (avatars.get(username)) return avatars.get(username) | ||
|
||
const img = await load(`accounts/${username}/user/img/img`) | ||
const name = await load(`accounts/${username}/user/name`) | ||
|
||
const avatar = { name: name[0], img } | ||
|
||
avatars.set(username, avatar) | ||
return avatar | ||
} |