Save and use excluded types
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
19f3177f66
commit
d4de6faa89
|
@ -54,8 +54,10 @@ type indexPage struct {
|
|||
type settingsPage struct {
|
||||
Session session
|
||||
|
||||
CurrentChannel microsub.Channel
|
||||
CurrentSetting channelSetting
|
||||
CurrentChannel microsub.Channel
|
||||
CurrentSetting channelSetting
|
||||
ExcludedTypes map[string]bool
|
||||
ExcludedTypeNames map[string]string
|
||||
|
||||
Channels []microsub.Channel
|
||||
Feeds []microsub.Feed
|
||||
|
@ -348,7 +350,7 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
page.CurrentSetting = channelSetting{}
|
||||
}
|
||||
// TODO: similar code is found in timeline.go
|
||||
// FIXME: similar code is found in timeline.go
|
||||
if page.CurrentSetting.ChannelType == "" {
|
||||
if v.UID == "notifications" {
|
||||
page.CurrentSetting.ChannelType = "stream"
|
||||
|
@ -356,6 +358,21 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
page.CurrentSetting.ChannelType = "sorted-set"
|
||||
}
|
||||
}
|
||||
page.ExcludedTypeNames = map[string]string{
|
||||
"repost": "Reposts",
|
||||
"like": "Likes",
|
||||
"bookmark": "Bookmarks",
|
||||
"reply": "Replies",
|
||||
"checkin": "Checkins",
|
||||
}
|
||||
page.ExcludedTypes = make(map[string]bool)
|
||||
types := []string{"repost", "like", "bookmark", "reply", "checkin"}
|
||||
for _, v := range types {
|
||||
page.ExcludedTypes[v] = false
|
||||
}
|
||||
for _, v := range page.CurrentSetting.ExcludeType {
|
||||
page.ExcludedTypes[v] = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -565,6 +565,37 @@ func (b *memoryBackend) channelAddItemWithMatcher(channel string, item microsub.
|
|||
b.lock.RUnlock()
|
||||
|
||||
for channelKey, setting := range settings {
|
||||
if len(setting.ExcludeType) > 0 {
|
||||
for _, v := range setting.ExcludeType {
|
||||
switch v {
|
||||
case "repost":
|
||||
if len(item.RepostOf) > 0 {
|
||||
return nil
|
||||
}
|
||||
break
|
||||
case "like":
|
||||
if len(item.LikeOf) > 0 {
|
||||
return nil
|
||||
}
|
||||
break
|
||||
case "bookmark":
|
||||
if len(item.BookmarkOf) > 0 {
|
||||
return nil
|
||||
}
|
||||
break
|
||||
case "reply":
|
||||
if len(item.InReplyTo) > 0 {
|
||||
return nil
|
||||
}
|
||||
break
|
||||
case "checkin":
|
||||
if item.Checkin != nil {
|
||||
return nil
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if setting.IncludeRegex != "" {
|
||||
re, err := regexp.Compile(setting.IncludeRegex)
|
||||
if err != nil {
|
||||
|
|
|
@ -84,11 +84,9 @@
|
|||
<div class="control">
|
||||
<div class="select is-multiple">
|
||||
<select name="exclude_type" id="exclude_type" multiple>
|
||||
<option value="repost">Reposts</option>
|
||||
<option value="like">Likes</option>
|
||||
<option value="reply">Replies</option>
|
||||
<option value="bookmark">Bookmarks</option>
|
||||
<option value="checkin">Checkins</option>
|
||||
{{ range $key, $excluded := .ExcludedTypes }}
|
||||
<option value="{{ $key }}" {{ if $excluded }}selected="selected"{{ end }}>{{ index $.ExcludedTypeNames $key }}</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user