-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev twitter api, style list of npubs
- Loading branch information
Showing
23 changed files
with
390 additions
and
48 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
frontend/nos-crossposting-service-frontend/src/components/Button.vue
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,32 @@ | ||
<template> | ||
<button @click="$emit('click', $event)">{{ text }}</button> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import {Options, Vue} from 'vue-class-component'; | ||
@Options({ | ||
props: { | ||
text: String | ||
}, | ||
}) | ||
export default class Button extends Vue { | ||
text!: string | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
button { | ||
background-image: linear-gradient(180deg, #F08508 0%, #F43F75 100%); | ||
padding: 19px; // input has 16px padding + 3px border | ||
border: 0; | ||
border-radius: 10px; | ||
color: #FFF; | ||
font-size: 32px; | ||
font-weight: 700; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
} | ||
</style> |
11 changes: 11 additions & 0 deletions
11
frontend/nos-crossposting-service-frontend/src/components/Checkmark.vue
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,11 @@ | ||
<template> | ||
<img class="checkmark" src="../assets/checkmark.svg"> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import {Options, Vue} from 'vue-class-component'; | ||
@Options({}) | ||
export default class Checkmark extends Vue { | ||
} | ||
</script> |
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
25 changes: 19 additions & 6 deletions
25
frontend/nos-crossposting-service-frontend/src/components/Input.vue
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 |
---|---|---|
@@ -1,30 +1,43 @@ | ||
<template> | ||
<input type="text" :placeholder="placeholder"> | ||
<input type="text" :placeholder="placeholder" :value="modelValue" @input="onInput"> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import {Options, Vue} from 'vue-class-component'; | ||
@Options({ | ||
props: { | ||
placeholder: String | ||
placeholder: String, | ||
modelValue: String, | ||
}, | ||
emits: [ | ||
'update:modelValue', | ||
], | ||
}) | ||
export default class Input extends Vue { | ||
placeholder!: string | ||
modelValue!: string; | ||
onInput(event: InputEvent): void { | ||
this.$emit('update:modelValue', (event.target as HTMLInputElement).value); | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
input { | ||
border-radius: 10px; | ||
border: 3px solid rgba(255, 255,255, 0.15); | ||
padding: .5em; | ||
margin: 1em 0; | ||
border: 3px solid rgba(255, 255, 255, 0.15); | ||
padding: 16px; | ||
background-color: #342255; | ||
min-width: 500px; | ||
color: rgba(255, 255, 255, 0.25); | ||
font-weight: 700; | ||
font-size: 32px; | ||
line-height: 32px; | ||
color: #fff; | ||
&::placeholder { | ||
color: rgba(255, 255, 255, 0.25); | ||
} | ||
} | ||
</style> |
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,54 @@ | ||
package adapters | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
|
||
"github.com/boreq/errors" | ||
"github.com/planetary-social/nos-crossposting-service/service/app" | ||
"github.com/planetary-social/nos-crossposting-service/service/domain/accounts" | ||
) | ||
|
||
const cacheTwitterAccountDetailsFor = 15 * time.Minute | ||
|
||
type TwitterAccountDetailsCache struct { | ||
entries map[string]twitterAccountDetailsCacheEntry // todo cleanup periodically | ||
entriesLock sync.Mutex | ||
} | ||
|
||
func NewTwitterAccountDetailsCache() *TwitterAccountDetailsCache { | ||
return &TwitterAccountDetailsCache{ | ||
entries: make(map[string]twitterAccountDetailsCacheEntry), | ||
} | ||
} | ||
|
||
func (t *TwitterAccountDetailsCache) Get(accountID accounts.AccountID, updateFn func() (app.TwitterAccountDetails, error)) (app.TwitterAccountDetails, error) { | ||
t.entriesLock.Lock() | ||
defer t.entriesLock.Unlock() | ||
|
||
entry, ok := t.entries[accountID.String()] | ||
if ok && entry.isUpToDate() { | ||
return entry.value, nil | ||
} | ||
|
||
newValue, err := updateFn() | ||
if err != nil { | ||
return app.TwitterAccountDetails{}, errors.Wrap(err, "error getting new twitter account details") | ||
} | ||
|
||
t.entries[accountID.String()] = newTwitterAccountDetailsCacheEntry(newValue) | ||
return newValue, nil | ||
} | ||
|
||
type twitterAccountDetailsCacheEntry struct { | ||
t time.Time | ||
value app.TwitterAccountDetails | ||
} | ||
|
||
func newTwitterAccountDetailsCacheEntry(value app.TwitterAccountDetails) twitterAccountDetailsCacheEntry { | ||
return twitterAccountDetailsCacheEntry{t: time.Now(), value: value} | ||
} | ||
|
||
func (e *twitterAccountDetailsCacheEntry) isUpToDate() bool { | ||
return time.Since(e.t) < cacheTwitterAccountDetailsFor | ||
} |
Oops, something went wrong.